On Wednesday 25 February 2004 06:26, Narayanan Ravi Chandran wrote: Hi,
> Hi, > > I am finding a typical problem with the below JSP code. The problem No wonder. Never seen anything like that. > is when I use the response.getOutputStream() to display the image > generated @ server the text and text boxes are never shown in the > page, I am getting only the image. > > Could some body help me on this. Well...something important first: HTML means *text*. Each and every web page is basically just simple and plain text. It may contains links to other resources, as is the case with <img> tags, but these are loaded in a separate request. It's the browser that finally fits the pieces together, so that the images seem to be 'embedded' in the page, but that's 'browser magic' and not related to the HTML protocol. Therefore, if you want to generate images to be displayed in your page, you have to split up your design into two different pieces at least: one Servlet that delivers the image as a binary stream (don't forget to set the MIME headers accordingly), plus the HTML page which con- tains the text. Map the image servlet to a name it can be called by (web.xml) and possibly wrap this to a Struts action (the standard forward action suffices). Then, replace the <%=response.getOutputStream()%> part with the image servlet path (/image.do, for example). To get an idea how this works: one of the projects I was recently involved in is www.anwalt4you.com. Each of the user pictures comes from an Oracle BLOB, with the byte stream generated on the fly by just the aforementioned Servlet (which is dead simple). Btw, the site runs on a Tomcat 5 cluster and heavily uses MVC2 and Struts 1.1. HTH, -- Chris (SCPJ2) > Thanks in advance. > RCDran -- CLIP! =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com
