File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: is forward can call after response generation