File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes OutputStream irritates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "OutputStream irritates" Watch "OutputStream irritates" New topic

OutputStream irritates

Padma Prasad
Ranch Hand

Joined: Sep 16, 2002
Posts: 76
I have a JSP page called prgfile, from which I call a servlet. I tried to call getOutputStream() of the ServletResponse in the servlet but got an error which said getOutputStream() is already opened. But i didnt open this any where before that servlet call. In the prgfile_jsp servlet, I found pageContext.getOut(). does this statement preventing me from calling the getOutputStream?
but all the JSPs shud have this getOut() called. so, how is it possible to call a o/p stream in another servlet?
can a outputstream object be sent as a parameter to the servlet so that in the servlet it can write to the browser either character data or image bytes.
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
How are you calling the servlet from the JSP?
Padma Prasad
Ranch Hand

Joined: Sep 16, 2002
Posts: 76
JSP -> Custom Tag Class -> Servlet.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
The JSP has already opened the output stream as a JspWriter so you can't open it again as an OutputStream.
The usual approach is to have a servlet get the initial request and dispatch to JSP because you have more control in a servlet.
I agree. Here's the link:
subject: OutputStream irritates
jQuery in Action, 3rd edition