thanks craig,
I think it should work this way.
thanks & regards,
Siddhartha
-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: den 21, december 1999 08:08
To: [EMAIL PROTECTED]
Subject: Re: Multiple setting of Content Type within the same Servlet.
Paresh M Gheewala wrote:
> Hi * I want to send image and Text from the same servlet. Is it
> possible ?
> Ans :To send the image and text from servlet is possiblebut once u
> start one servlet then for again restarting uhave to restart the Java
> WEB server .
This is not correct.
What you need to remember is that, when an HTML page includes an <img>
tag to load an image, that image is downloaded with a ***separate***
request from the one that received the HTML page.
Generally, what you want to do with your servlet is create the HTML
output. It is perfectly legitimate for the HTML code you generate to
include an <img> tag. It is also perfectly legitimate for that <img>
tag to have a "src" attribute that is the URL of a servlet -- perhaps
even the same servlet that created the HTML page in the first place.
Why would I ever want a servlet to produce an image? Consider a stock
quote application, like the one at http://finance.yahoo.com. The graphs
that you request are dynamically generated (based on the time frame and
graph size you select, along with the stock symbol of the stock you are
interested in). But the request to create the graph is separate from
the request to create the page itself.
If you use the same servlet, you would have to examine the request URI
of the incoming request and decide whether this particular request was
for the HTML page (in which case you would set the content type to
"text/html") or an image (where you would set the content type to
"image/gif" or whatever was appropriate for your image format). Under
no circumstances would you be sending both responses to the same
request, so there is no need to attempt to set the content type twice.
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
