aspose file tools*
The moose likes JSP and the fly likes Using response.setcontenttype Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using response.setcontenttype" Watch "Using response.setcontenttype" New topic
Author

Using response.setcontenttype

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
Hi all,
If I want to see the response of my jsp as a text file in the browser, can I use response.setContenttype in jsp ?
If so, can anyone give me a piece of code ?
Maya
Sakti Singh
Greenhorn

Joined: Dec 13, 2000
Posts: 16
yes,
try this:
-----------
response.setContentType("text/html")
thanks
Sakti
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
response.setContentType("text/plain");
- Peter
Dariusz Lubaczewski
Greenhorn

Joined: Nov 28, 2003
Posts: 1
If I want to make the response of my jsp as a file on the disc, can I use response.setContenttype in jsp?
If so, what should be the code?
now I have:
response.setContentType("text/plain; charset=windows-1250");
but it takes jsp to the browser - can anyone help me?


=====<br />DaRek
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

D.L. --
Welcome to JavaRanch!
We ain't got many rules round these parts, but we do have our naming policy, which requires that your display name be a first and last name; the last name must be at least two letters and the whole name must at least sound real. Please head over here and change yours, pronto. Thanks, pardner, and hope to see ya around the Ranch!
Now, as to your post: note that if you've got a new question to ask, you oughta start a new thread. They're cheap, and it's a better way to get your question noticed than hitchin' onto somebody else's wagon.
To answer your question: if you mean that you want the response to force the browser to throw up a "save file" dialog, try using the MIME type "application/octet-stream" instead of "text/plain".


[Jess in Action][AskingGoodQuestions]
bj bj
Greenhorn

Joined: Apr 28, 2004
Posts: 3
hello i have a problem with setContentType in JSP
i put in my Jsp file :
response.setContentType("application/pdf");
but my i.e no understand and no open the file with Acrobat Reader
anyone know that?
bj bj
Greenhorn

Joined: Apr 28, 2004
Posts: 3
even if i put response.setContentType("text/html");
i.e doesn't want to open the file ?!?!
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you can't just set the contenttype. You also have to make sure the generated data is really of that type or the browser will barf


42
bj bj
Greenhorn

Joined: Apr 28, 2004
Posts: 3
i use pdflib so the file is a pdf but i have a box that says that the file can broke the computer !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

"bj bj",
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Thanks!
bear
JSP Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using response.setcontenttype