i want to download images of any type from the server.my server is unix based.i need help help in coding.what should i give as content type in the response of jsp. i am using jsp. i had given image/jpg or image.gif as content type.but it is giving error as no preview parameters. help me.. thanks pravii
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12267
1
posted
0
JSP is optimized for text - images are binary. The best way to serve binary data is through a servlet where you have total control over the response and can set the content type and length. Servlets are just as simple as JSP, after all, a JSP is turned into a servlet. There is no reason not to use a mix of JSP and servlets for your application. Bill
I've got an issue with this approach... I have a JSP file that has the following (<> removed so you can see the syntax): IMG SRC="/servlet/imageservlet?id=6" The problem is when I refresh the page, sometimes the image appears, sometimes it doesn't... The same code, pointing to a PHP file for image retrieval works just fine... Any suggestion? P.S. The "id=" is pulling the image from a mySQL DB given the "id" of the image table.
Dave Van Even
Ranch Hand
Joined: Jul 19, 2001
Posts: 101
posted
0
just MAP the servlet to a file with the right extension.. also make shure you write the right response content type !!
res.setContentType("image/gif"); and map the servlet to somthing like: /imageservlet.gif