This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes is forward can call after response generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "is forward can call after response generation" Watch "is forward can call after response generation" New topic
Author

is forward can call after response generation

balakrishna nannaka
Greenhorn

Joined: May 08, 2006
Posts: 3
if forward or request dispatcher can call after generating some respone in the servlet which is called
Harpreet Hira
Ranch Hand

Joined: Sep 27, 2001
Posts: 72
What do you mean by generating some response?
You can forward a request to another resource, if you have NOT committed(flushed) response to the browser.

You must be thinking how "committing a response" is different from "generating some response" ?
Generally we take a PrintWriter(out) from response and do out.println() to write something to response. This is NOT committing the response. The response is committed either on calling flush() explicitly, or when the response size increases the buffer size(8KB is default buffer size) or when you service() method completes execution and control goes back to Servlet Container.

So, in a nutshell, if you have NOT flushed the data in a servlet or JSP and NOT exceeded the buffer size you can forward the request to some other resource in the same context.
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
It's possible if chunked transmission used.


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: is forward can call after response generation
 
Similar Threads
forward() can be include()...
Mock Question
RequestDipatcher
Regarding RequestDispatcher.forward
RequestDispatcher doubts