--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("image/png");
if(request.getParameter("id") != null) {
if(request.getParameter("id").equals("")) {
response.sendError(500, "Bad request | Please provide an existing ...?id=X");
}
else {
int mapID = Integer.parseInt(request.getParameter("id"));
byte[] image = null;
try {
yourClientWrapper wrapper = yourDao.readById((long) mapID);
image = wrapper.getYourImage();
}
catch (Exception e) {
e.printStackTrace();
}
OutputStream out = response.getOutputStream();
out.write(image);
out.close();
}
}
else {
response.sendError(500, "Bad request | Please provide an existing id with ...?id=X");
}
}
On the client side: You just insert your Servlet-Url as the Image Resource (src-Attribute) like http://www.yourfancyurl.com/yourgwtapplication/servlet/imageGetter?id=31) and that's it. The servlet returns the image to the corresponding id without saving it to the disk.