[Web-SIG] [server-side] request/response objects

Geoffrey Talvola gtalvola at nameconnector.com
Tue Oct 28 18:08:52 EST 2003


Moof wrote:
> An example where a separate response object is useful, though
> this could
> well be due to lazy programming, or could be circumvented other ways:
> 
> I'm currently writing an app in WebKit, and amongst other
> things, I find
> myself writing parts of the page, followed by doing some calculations,
> followed by writing other parts of the page. Alternatively, I find
> myself validating user input and doing calculations, and then writing
> the whole page as a result. Either way, if there's an error
> that occurs
> somewhere along the line, due to faulty input, I tell the page to
> forward the request to another servlet that can handle the errors
> (normally right back to the servlet that generated the form that
> inputted the faulty data). 
> 
> It's a bit of a poor man's exception, because Page.forward() doesn't
> *actually* break out of the current context, so I need to break out
> manually, either with a break statement or more normally by continuing
> til an uncaught exception is thrown.

Actually, in Webware CVS Page.forward() _does_ break out of the current
context by raising an EndResponse exception that gets caught in the
framework.  You are probably using a released version of Webware which
doesn't work this way, but instead substitutes a "dummy" response object for
the real response object to swallow up any output from the original servlet.

I agree with your point, which I take to be this: it's nice to be able to
throw away any response that may have accumulated so far and re-process the
request.  And that seems to argue for separate request and response objects.

> 
> The forward directive will be taken into account as soon as the page
> ends, and will just delete the current response object and call the
> forwarded servlet with a new response object which will buffer and
> eventually send out the data that the servlet eventually generates.

I don't think this is how WebKit ever worked.  I'm pretty sure that both in
current Webware CVS and in previous releases, the forwarded-to servlet
processes the request immediately, not when the page ends.

> 
> Then again, it could just be lazy programming on my part.


- Geoff



More information about the Web-SIG mailing list