File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward doubts ?

 
Sebastien French
Greenhorn
Posts: 26
Firefox Browser Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I doubt about the forward functionnality.

When forwarding from servlet 1 to servlet 2. Do we get back to servet 1 after servlet 2 complete ?

I'm allmost sure control get back to servlet 1 but ...
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2167
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you will get back, but you can't really do anything any more with the response, as it is committed.

Regards,
Frits
 
Paul Clapham
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add to that a bit: that means that after you call the "forward" method in servlet 1, the code after that will indeed be executed. A lot of people seem to think that calling "forward" is like a GOTO statement, but of course it's just a Java method like all the others.

I don't know whether the code in servlet 2 will be executed before or after the code which comes after the "forward" in servlet 1, but I do know that both will be executed. (And I don't really care either -- if I did then the two servlets would be closely coupled and that would be a design problem.) And as Frits says, servlet 1 shouldn't do anything with the response after forwarding. However you're likely to want to do things like closing database connections after you forward to servlet 2.
 
Sebastien French
Greenhorn
Posts: 26
Firefox Browser Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic