Need help w. getOutputStream( )

S

Steve Burrus

I need some pretty immediate help w. using the getOutputStream() servlet
method to be able to see an image in my web browser!! Can anyone
possibly help me with this please???
 
G

Gordon Beaton

I need some pretty immediate help w. using the getOutputStream()
servlet method to be able to see an image in my web browser!! Can
anyone possibly help me with this please???

I don't know what kind of a response you were hoping for, but it
usually helps if you actually ask a question. If someone can help,
they will.

/gordon
 
S

Steve Burrus

Gordon said:
I don't know what kind of a response you were hoping for, but it
usually helps if you actually ask a question. If someone can help,
they will.

/gordon

Well gordon, if u didn't quite understand my question that was posed
last nite, I will say that I simply want to be able to get an image into
a servlet to be viewed by my browser, i.e., a .gif and/or a .jpeg kind
of an image! I tried to use that "getOutputStream()" method to do this,
but the compiler returned an error saying that there was return value in
the method! I just want to know how to use this method to see an image.
 
J

John C. Bollinger

Steve said:
Well gordon, if u didn't quite understand my question that was posed
last nite, I will say that I simply want to be able to get an image into
a servlet to be viewed by my browser, i.e., a .gif and/or a .jpeg kind
of an image! I tried to use that "getOutputStream()" method to do this,
but the compiler returned an error saying that there was return value in
the method! I just want to know how to use this method to see an image.

You cannot use getOutputStream() to "see" an image. You _can_ use
getOutputStream() to make the servlet send an image to its client, which
might be your web browser. To do so you write the bytes of the image to
the OutputStream returned by the method. It will probably work better
if you set an appropriate content-type header on the response first. If
you are having problems implementing this scheme then you'll probably
need to post the code and the actual text of any error messages to get
much further assistance.


John Bollinger
(e-mail address removed)
 
S

Steve Burrus

John said:
You cannot use getOutputStream() to "see" an image. You _can_ use
getOutputStream() to make the servlet send an image to its client, which
might be your web browser. To do so you write the bytes of the image to
the OutputStream returned by the method. It will probably work better
if you set an appropriate content-type header on the response first. If
you are having problems implementing this scheme then you'll probably
need to post the code and the actual text of any error messages to get
much further assistance.


John Bollinger
(e-mail address removed)

Hi John, this is steve Burrus, and here is the requested servlet code
for this image servlet which has absolutely proven to be so very
problemmatic for me!! I just now tried to compile it, and got back the
compiler error message about the "response" being an unrecognized
symbol! NOw, what is the problem?? :
servlet!
// here is the code to examine, John Bollinger!!!
package com.theresa.heinz;

import java.io.*;
import java.awt.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ImgServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ServletOutputStream out = reponse.getOutputStream() ;

out.println("<html><head><title>Image Servlet</title></head>");
out.println("<body>");
out.println("<p><img
src=\"myservlets/images/tomcat-power.gif\"</img src></p>");
out.println("</html></body>");
out.close();

}

}"<<

And here is the full compiler error :
cannot find symbol
symbol : variable reponse
location: class com.theresa.heinz.ImgServlet
ServletOutputStream out = reponse.getOutputStream() ;
^
1 error"<<
 
S

Sudsy

Steve said:
Hi John, this is steve Burrus, and here is the requested servlet code
for this image servlet which has absolutely proven to be so very
problemmatic for me!! I just now tried to compile it, and got back the
compiler error message about the "response" being an unrecognized
symbol! NOw, what is the problem?? :
public class ImgServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)
And here is the full compiler error :

symbol : variable reponse
location: class com.theresa.heinz.ImgServlet
ServletOutputStream out = reponse.getOutputStream() ;
^
1 error"<<

Why don't you actually READ the diagnostic before coming to this ng
with the attitude that THERE MUST BE SOMETHING WRONG WITH THE COMPILER?
If you take a moment to stop and think things through you'll see that
your line of code uses 'reponse', not 'response'.
IOW, you've made a typing mistake and omitted the first s from the
word response.
The error message is entirely correct. The error was on your part.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,787
Messages
2,569,631
Members
45,339
Latest member
RandiMarti

Latest Threads

Top