Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward() in Servlets

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose one servlet forwards a request to another servlet, and the second servlet in turn forwards the request to the first servlet, will it result to an infinite loop? What should I do to avoid this?
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
exactly...it would do the same as you said it.
But what exactly are you trying to do...??
Please pass on some more info..
cheers
MB
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What should I do to avoid this?

Well, the simple answer is: Don't do that!
In the same way you must guard against creating infinite loops in code -- especially when using recursion -- if you have such a situation where it is possible for your servlets to get stuck in this way (I'd also argue that such a situation merits sitting back and pondering whether your design needs some rethinking), you need to place safeguards into the code to make sure that you never get into an inifinite-forward loop.
hth,
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic