Re: Html/jpg from db to client?
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] -- Jeffrey Bonevich Ann Arbor, Michigan [EMAIL PROTECTED] http://www.bonevich.com Hwæt! Wë Gär-Dena in geär-dagum, peod-cyninga, prym gefrünon, hü ða aepelingas ellen fremedon! -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
RE: Html/jpg from db to client?
how do you store your image files in your DB? as BLOB objects or as references to image files at some location? Ozgur. -Original Message- From: john-paul delaney [mailto:[EMAIL PROTECTED]] Sent: Monday, April 22, 2002 3:15 AM To: Tomcat Users List Subject: Re: Html/jpg from db to client? 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] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Html/jpg from db to client?
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]
Html/jpg from db to client?
Hello List... Using a servlet, I retrieve an image from a database, but I want to send it in a formatted html page to the client... any suggestions on how to approach this (combining html and streaming images) appreciated. thanks /j-p. --- JUSTATEST Art Online www.justatest.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Html/jpg from db to client?
Yes, make the image element's src attribute a call to a servlet that just streams out the image. So for example, in your HTML page you have: img src=http://mydomain.com/mywebapp/imagestreamservlet?imageID=xxx; Then the 'imagestreamservlet' does the image lookup and streams it out to the response writer (i.e. response.setContentType(image/gif) or image/jpeg, or whatever, then grab response.getWriter() and start writing bytes from a reader on the image file to it). The only sticking point is that you do not know the image dimensions before grabbing the image (duh!), so if you need width/height info for the image in the page, it may be worthwhile having the HTML page also produced by a servlet that also looks up the image, but only retrieves metadata about it and sticks it in the appropriate places. jeff john-paul delaney wrote: Hello List... Using a servlet, I retrieve an image from a database, but I want to send it in a formatted html page to the client... any suggestions on how to approach this (combining html and streaming images) appreciated. thanks /j-p. --- JUSTATEST Art Online www.justatest.com -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- Jeffrey Bonevich Ann Arbor, Michigan [EMAIL PROTECTED] http://www.bonevich.com Hwæt! Wë Gär-Dena in geär-dagum, peod-cyninga, prym gefrünon, hü ða aepelingas ellen fremedon! -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Html/jpg from db to client?
Hello List... Using a servlet, I retrieve an image from a database, but I want to send it in a formatted html page to the client... any suggestions on how to approach this (combining html and streaming images) appreciated. 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. Nix.
Re: Html/jpg from db to client?
On Sun, 21 Apr 2002, Jeffrey Bonevich wrote: Thanks Jeff... I'll try this out - following your suggestion, I was thinking to put the dimensions of the image (jpg) in the database too and to retrieve it along with the image - the html will be a combination of includes and dynamic written by the servlet. Don't know if this is really a relevant question - from a design point of view, is it better to use one servlet to handle all of this or multiple chained servlets? regards /j-p. img src=http://mydomain.com/mywebapp/imagestreamservlet?imageID=xxx; The only sticking point is that you do not know the image dimensions before grabbing the image (duh!), so if you need width/height info for the image in the page, it may be worthwhile having the HTML page also produced by a servlet that also looks up the image, but only retrieves metadata about it and sticks it in the appropriate places. -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Html/jpg from db to client?
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]