aspose file tools*
The moose likes Servlets and the fly likes servlet not printing image file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet not printing image file" Watch "servlet not printing image file" New topic
Author

servlet not printing image file

Raj Puri
Ranch Hand

Joined: Apr 24, 2003
Posts: 189
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

Joined: Sep 08, 2004
Posts: 117
You do getWriter for charecter data. Try getOutputStream method instead!


SCJP,SCWCD(1.4)
Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
Also look at the ouput after your code has run. Does the tag look the way you intended it too?

Eric
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

What is the URL that you're using for your servlet?
[ February 17, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet not printing image file