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

Moof moof at metamoof.net
Tue Oct 28 17:49:45 EST 2003

Greg Stein wrote:

 > When you stop and think about it: *every* request object will have a
 > matching response object. Why have two objects if they come in pairs? You
 > will never see one without the other, and they are intrinsically tied to
 > each other. So why separate them?

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.

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.

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

            Giles Antonio Radford, a.k.a Moof
Sympathy, eupathy, and, currently, apathy coming to you at:

More information about the Web-SIG mailing list