Stream custom image from servlet via jsp call
Posted on 2003-11-02
I have a jsp that calls a servlet to display an image created on the fly. The image display works fine when the call to the servlet is made via a jsp:forward, but does not display when I do a jsp:include. I have additionaly functionality in the jsp page that I would rather not write out from the servlet, so that's the reason for the jsp->servlet call.
Again, I'd like to use <jsp:include page="/servlet/TestServlet" />
The relevant code in "TestServlet" is as follows:
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException
ServletOutputStream out = res.getOutputStream();
BufferedOutputStream bout = new BufferedOutputStream(out);
/* do some code here */
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bout);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
Thanks for your help.
Anyone here ever use ImageJ API to do on-the-fly image generation? Additional question and points.