?
Solved

Setting Content type in JSP

Posted on 2003-02-27
6
Medium Priority
?
194 Views
Last Modified: 2010-04-01
The default content-type set by the JSP engine is text/html.
Is it possible to set content-type in the JSP to anything other than text/html like say image/gif ?

I think it couldn't be done in JSP specifications 1.1 and earlier. What about in later JSP specs like 1.2 or 2.0 ?

Or are there any hacks around, for this problem ?

Thanks in advance,

Prabhu
0
Comment
Question by:prabhukrishnan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Accepted Solution

by:
allahabad earned 100 total points
ID: 8039730
I beleive, you can't. You can use servlet for this. Set ContentType("image/gif") for HttpServletResponse object.

 public void doGet(HttpServletRequest req, HttpServletResponse res)
   throws ServletException, IOException{

         res.setContentType("image/gif");

         try{
           --- code    
         }
}
0
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 8039748
jsp is designed for return text data and not bionary data.
If you want to return binary data then use a servlet.
0
 
LVL 9

Expert Comment

by:mglxxx
ID: 8040040
<%@ page contentType="your type here" %>

I agree with objects: if you are returning binary
data, you should use a servlet.  
0
 

Expert Comment

by:otitcsg
ID: 8048009
wah liaoooooooo
0
 
LVL 35

Expert Comment

by:girionis
ID: 9990335
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between allahabad and objects

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question