Srikanth: Not sure if it helps, but what I do is start building the reply
page in an object (I use HTML generator classes), and if an error occurrs I
build a seperate reply page & display that rather than the original. If I
get to the end of processing & no error, display the normal reply page. Kind
of takes advantage of the page-at-a-time nature of HTML, but I'm not sure if
it's applicable to your situation. It's basically option 2 on your list.

Mike N.

-----Original Message-----
From: Srikanth Ranganathan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 29, 1999 12:15 PM
To: [EMAIL PROTECTED]
Subject: Re: An alternative to sendRedirect()
orRequestDispatcher.forward()


I am struggling with the same problem. I would like to clean out the
print writer buffer, and substitute it with the contents of the error
message.

Does anybody have ideas as to deal with exceptions / error messages, when a
partial
response has been written into the printwriter out stream ?


-Srikanth

Neal Kaiser wrote:

> I've realized one problem (and am still looking for a good solution). Let
> me explain how a sample JSP flows:
>
> <Database Query is Done>
> Things printed to PrintWriter
> <Another Database Query is Done>
> This printed
> ...etc
>
> Now my <Database Query Done> tags can do a sendRedirect if there is an
> error executing the SQL.
>
> So, say my first database query is done, then things are printed, then the
> second query bombs. It will try to do a sendRedirect, which ofcourse won't
> work because the servlet output stream has been written to. (Aside note,
> this DID work with build 131 - but according to the spec, it probably
> shouldn't have).
>
> As I see it, my options are to either:
>
> 1) Do all queries at the top of the JSP before any HTML is printed. The
way
> the JSPs are structured, this would not really be acceptable.
>
> 2) Somehow have my "out" PrintWriter really be a buffer. Then, when
> everthing is done, print to the real output stream.  I'm not sure how
> possible this would be....
>
> Any other ideas?
>
> Thanks.
>
> At 09:25 AM 4/29/99 -0400, you wrote:
> >I am using the latest JRun build (140) and much of my JSP functionality
is
> >failing.  In many of my JSPs, I do some preliminary processing of a
> >request, and if certan conditions are met, I forward the request to
another
> >JSP for processing.
> >
> >I do all this BEFORE anything is written to the PrintWriter (Servlet
> >OutputSteam).  This previously worked w/ build 131, but now doesn't. I've
> >tried the RequestDispatcher.forward() also, no luck. In reading the spec,
> >it says "You cannot use this method if the PrintWriter object has been
> >obtained from the response..."
> >
> >Well, when JRun compiles a JSP to a JAVA file, one fo the first lines in
> >the service() method is:
> >
> >PrintWriter out = new PrintWriter (new BufferedWriter( new
> >OutputStreamWriter(Response.getOutputStream())),true)
> >
> >How can I get around this? I want to be able to forward requests, but
> >cannot because getOutputStream has been called.
> >
> >Thanks,
> >
> >Neal Kaiser
> >
> >------------------------------------------------------------
> >To unsubscribe, send email to [EMAIL PROTECTED]
> >and include in the body of the message "unsubscribe jrun-development".
> >
> >
>
>
___________________________________________________________________________
> 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

___________________________________________________________________________
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

___________________________________________________________________________
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

Reply via email to