• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Problem in using SimpleStream example with jsp

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am facing problems in using the SimpleStream example given in the servlets section for securely getting images on our webpages. i am using the following code in jsp file in order to call the SimpleStream servlet


it gives me the following error when i run the jsp page

java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.catalina.connector.Response.getWriter(Response.java:607)

now i understand that the problem is with the response object that i send from the jsp file which has already called an outputstream. can anyone tell me how i can overcome the problem and get the image on my page.another thing is it possible to place the image using the image tag when i get it using the SimpleStream servlet???
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by nick sharma:
another thing is it possible to place the image using the image tag when i get it using the SimpleStream servlet?


That is the only way to do it. You can't send the image and its page in the same response. The page will request the image using an <img> tag that references the servlet that will serve the image, and only the image.
 
nick sharma
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry but i did not understand the reply.are you telling me that the request dispatcher need not be called and that i should give the servlets address as the location of the image???
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It sounds from your first post that you are trying to send the image data and the HTML page in the same response. This you cannot do. If that's not what you are doing, you'll need to explain what it is that you are doing a bit more clearly.
 
nick sharma
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks i got the reply.that was very stupid of me not to try the image source in the first place
:p
 
nick sharma
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i was trying to get the image from the servlet using the include directive.i know pretty dumb when i should actually use the src variable in the image tag to make life easier sorry for bothering with such a simple thing

Regards
Nick
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic