Hi Iacopo,
Following my answer in the "Servlets or JSP" thread... why would you use
a JSP page to do this when there's almost no GUI at all? Wouldn't it be
better to do the same thing with a servlet and if anything goes wrong
forward the request to an error page(if you want any possible GUI to be
out of the servlet)?. That's the approach I'm using and I'm quite happy
with it, so is there any advantage in using JSP in this case that I'm
not aware of?
Regards,
Dan
-------------------------------------------
Daniel Lopez Janariz ([EMAIL PROTECTED])
Web Services
Computer Center
Balearic Islands University
-------------------------------------------
Iacopo Sassarini wrote:
>
> How can I generate bynary content (say, a serialized java object) from a
> JSP 1.0 page??
> In previous JSP versions it was possible to write directly to the
> response output stream and my code worked.
> With JSP 1.0 this seems to be not possible, in fact the following piece
> of code
>
> <%@ page contentType="application/octet-stream" buffer="none" %>
> <%
> response.setHeader("Content-transfer-encoding", "BINARY");
> MyObj x = new MyObj();
> ServletOutputStream outStream = response.getOutputStream();
> ObjectOutputStream objStream = new ObjectOutputStream(outStream);
> objStream.writeObject(x);
> objStream.close();
> %>
>
> generates the error java.lang.IllegalStateException: Already called
> getWriter() (JRun 2.3.2 build 152).
>
> The error seems to be OK because 1) according the JSP1.0 spec the JSP
> engine have to initially set the out variable to an instance of the
> JspWriter (obtained by PageContext.getOut() which in turn probably calls
> response.getWriter() and 2) according to Servlet API it is not possible
> to call the getOutputStream() method after having called the getWriter()
> method of the response object.
>
> So, how can I do? Please...HELP!
>
> Iacopo
>
> P.S.
> If I allow buffering then the binary output is correctly generated but
> at the end of the page the error message
> java.lang.IllegalStateException: Already calledgetOutputStream() is
> appended (probably generated by the out.flush() call which calls
> getWriter() ?)
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".