aspose file tools*
The moose likes Servlets and the fly likes I have no idea why this is happening Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "I have no idea why this is happening" Watch "I have no idea why this is happening" New topic
Author

I have no idea why this is happening

Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
hi all,
i found out something very strange thing abt servlets.i dont know if i am right but anyway....
in one of my servlets, if a particular condition is met i forward the request to a certain jsp page

and if the condition is not met i do some other processing in the servlet itself.today i realized that the request comes back to this servlet after the jsp page execution is over.till now i believed that once request has been forwarded, the control passes on to the called servlet/jsp page.
am i right?if i am right what should i do so that the request doesn't come back to the calling servlet.i know i can use the else condition.but in my case there are situations where i cannot use else condition
any help would be greatly appreciated.
Subbu


Subbu
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
According to the API, when the call to forward returns, the response output stream should be flushed and closed, so your calling servlet should not be able to write anything more. However, the thread that calls forward does return to the calling method, so you can do other stuff.
Bill

------------------
author of:
Subbu Aswathanarayan
Ranch Hand

Joined: Jun 22, 2001
Posts: 73
thanks bill for your response.
is there anyway i can prevent the execution of the code after the forward statement.can i use something like exit just after the forward statement.is it advisable?
thanks.
Subbu
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I have no idea why this is happening