This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet Response Type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Response Type" Watch "Servlet Response Type" New topic
Author

Servlet Response Type

Yans Tan
Greenhorn

Joined: Jul 11, 2006
Posts: 29
Hi there! I have got some questions here.

Currently I am trying to do this

response.setContentType("image/gif")
ServletOutputStream out = response.getOutputStream();
response.setContentType("text/html;charset=UTF-8");
PrintWriter out2 = response.getWriter();


But i think that the second setContentType is overwritting to the first one.
Anyone have any idea to over come this?

Thx in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

Originally posted by Yans Tan:
Anyone have any idea to over come this?


Yes, don't do that. What are you trying to accomplish?

As I pointed out in your other topic, you can't mix HTML content and image content in one response. You need to write an <img> tag in the the HTML which make a request back to a servlet that will stream the image data (and only the image data).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yans Tan
Greenhorn

Joined: Jul 11, 2006
Posts: 29
Okay I get what you mean. I solved it already Thx!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Response Type
 
Similar Threads
The requested method POST is not allowed for the URL
What is the problem?
Is there a solution?
Problems with Tomcat
Java Dynamic Servlet