Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

OutputStream irritates

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Thanks,
Padma.
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you calling the servlet from the JSP?
 
Padma Prasad
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP -> Custom Tag Class -> Servlet.
Padma.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Bill
 
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic