Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet not printing image file

 
Raj Puri
Ranch Hand
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a gif file in image directory under webapps/myapp/. The following code should print that gif file and does not. I played around with all combination of ptah to gif like ., ../.. etc nothing seems to work, however the message does print fine. Only image is missing. Can I print a gif file in this way from servlet?

Thanks

------------------>

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"../stylesheet.css\" title=\"Style\">");
out.println("</head>");

out.println("<body bgcolor=\"white\">");
out.println("<img src=\"../../../images/show-calendar.gif\" width=24 height=22 border=0>");
out.println("<table style=\"border-style: double; 8px; border-color: 007FFF;\" cellspacing=\"10\" width=\"300\" align=\"center\" valign=\"top\" >");
out.println("<tr>");
out.println("<td>");

out.println("<span class=\"bnew\">Report Encountered Error, Please Make Note Of The Following And Hit Back Button To Continue:</span>");

e.printStackTrace(out); out.println("</td>");
out.println("</tr>");

out.println("</table>");
out.println("</body>");
out.println("</html>");
 
Ritu varada
Ranch Hand
Posts: 117
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do getWriter for charecter data. Try getOutputStream method instead!
 
Ritu varada
Ranch Hand
Posts: 117
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, set your content type to accomodate gif type. I am not sure of the correct one but search for different mimes types. You will get one for gif/jpeg.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also look at the ouput after your code has run. Does the tag look the way you intended it too?

Eric
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the URL that you're using for your servlet?
[ February 17, 2005: Message edited by: Ben Souther ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic