• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in using SimpleStream example with jsp  RSS feed

 
nick sharma
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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???
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!