[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[Home]
Re: Setting Content-Type from JSP
well, cool. Thanks for letting me know. I ended up writing a servlet to do
this, but now that I know how to do it through a jsp, I'll probably convert
it.
thanks!
eric
-----Original Message-----
From: Vincent Partington <vincentp@xs4all.nl>
To: Eric B. Ridge <ebr@tcdi.com>
Cc: gnujsp@gjt.org <gnujsp@gjt.org>
Date: Friday, January 29, 1999 1:30 AM
Subject: Re: Setting Content-Type from JSP
>Hi Eric,
>
>"Eric B. Ridge" wrote:
>> How can I set the Content-Type from a JSP. I don't always want to
>> send text/html. In this particular case I want to send image/gif.
>
>You can set the content-type by using the
><%@ content_type="image/gif" %>
>directive.
>
>If you are going to send binary data, your plan may be spoiled by the
>fact that output is sent for every bit of whitespace in your JSP page.
>What I did to solve this problem, was something like this:
>====> start of binary.jsp
><%@ method="dummyMethod" %>
><SCRIPT runat=server>
> public void service(HttpServletRequest req, HttpServletResponse res) {
> ... do something with res.getOutputStream() ...
> }
></SCRIPT>
>====> end of binary.jsp
>The automatically generated method is called "dummyMethod" and the
>method defined in the SCRIPT-tag is the one really used. The
>out.print()'s generated for the newlines on lines 1 and 6 are put in
dummyMethod.
>
>This feels a little like a hack (a way of writing regular servlets using
>the JSP system), but I hope this can be of some use to you.
>
>Regards, Vincent.