Paulo,

When you write normal HTML (not JSPs), how do you normally do this?  In your
HTML page, you have something like:

<HTML>
        <BODY>
                <IMG src="http://www.imagesource.com/helloWorld.gif"> </br>
                Hello World!
        </BODY>
</HTML>

When you want to dynamically create an image, the only thing that ought to
change is
the URL in the src paramater of the image tag.  In this case, it will point
to the
JSP (or preferrably Servlet) which creates your image.

The key is that you cannot mix different content types withing on http
response.
response.setContentType is setting the header of the response.  Actually
creating the
image sends the body of the response - it doesn't make sense to add another
header
immediately afterwards.  This is one of the reasons it is probably not a
good idea to
use JSPs to create images.  Yes, it works just as well, but it also could
fool one into
thinking that, as with other JSPs, regular HTML text can be mixed in.  This
is not the case.

It might also help to understand how browsers deal with images within html.
My understanding is
that the original http request for an html page downloads only the HTML.
Separate requests are
then created for each image tag, requesting the resources identified by
those URLs.  The browser
interprets the HTML to figure out where to render the results of those
images.

-AMT

> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Paolo Sommaruga
> Sent: Friday, March 10, 2000 4:31 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Dynamic Images
>
>
> Cool ! How to mix image with html ? i.e., how to put
> a textual "Hello World !" after the image ?
> I have tried to put after your code
>
> <%
>  out.flush();
>  response.setContentType("text/html");
> %>
>
> <br>
> hello world !!!
>
>
> but, don't works
>
>
>                 Paolo Sommaruga
>
> >
> >As a follow-on to Christian Mallwitz's example, here is a JSP
> that creates a
> >JPEG dynamically using the AWT and the JPEGImageEncoder. I have
> tested this
> >only under JSP 1.1.
> >
> >
> >
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to