Are there any examples of these techniques available? thanks /j-p.
On Mon, 22 Apr 2002, Jeffrey Bonevich wrote: > Nope. Only need two at most. Each of them sets their own content type > (image streamer sets it to "image/jpg", HTML producer to "text/html"). > And in answer to your other question, yes, this could be reduced to just > one servlet that does conditional setting of content-type and content. > But you will then need a querystring (or other) key/value pair to do the > conditional on. Suppose your HTML page url is /servlets/showimage/1. > Suppose the "1" in the subpath is the id for the image. Then you need > to have a switch in the URL to tell it whether you are getting html or > image: /servlets/showimage/1?show=1 > > SO now your HTML page is accessed with the URL /servlets/showimage/1 and > inside that page is embedded an <img src="/servlets/showimage/1?show=1" > height=" + image height + " width=" + image width + " ...>. > > Then in your showimage servlet, you grab the "show" request parameter > and, if it is present/equals 1, then set content type to image and > stream the image, otherwise set content type to html and output HTML (or > forward to JSP - just be sure to stick the image info somewhere in a > context so you can access it in the JSP page). > > Make sense? > > jeff > > john-paul delaney wrote: > > > On Mon, 22 Apr 2002, Nikola Milutinovic wrote: > > > > Thanks Nix... then I'm thinking I need three servlets to handle for each page sent >to the client... 1. Write the html header, 2. Get image from db and send the image, >3.Add in dimensions to <img tag> & add the footer. > > > > Is this correct? > > > > regards > > /j-p. > > > > > >>If you wish to send BOTH html and the image in the same invocation of the servlet, >then you're mistaken. HTTP/HTML, in general, doesn't work that way. You should make a >servlet which can retrieve a single picture, something like: > >> > >>/servlets/showImage?src=my_test_pic.gif > >> > >>Then make your servlet accept "src" parameter, retrive the image from the >database. Based on the extension you should set the correct MIME type, in this case >"image/gif" and send it. You should set Response->contentType to your MIME type and >open a servlet output stream in the Response and just splash your image into it. > >> > > > > > > ----------------------- > > JUSTATEST Art Online > > www.justatest.com > > > > > > > > > > -- > > To unsubscribe: <mailto:[EMAIL PROTECTED]> > > For additional commands: <mailto:[EMAIL PROTECTED]> > > Troubles with the list: <mailto:[EMAIL PROTECTED]> > > > > > > > > > ----------------------- JUSTATEST Art Online www.justatest.com -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>