File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes forward() in Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "forward() in Servlets" Watch "forward() in Servlets" New topic

forward() in Servlets

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
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
Ranch Hand

Joined: Aug 17, 2001
Posts: 399 would do the same as you said it.
But what exactly are you trying to do...??
Please pass on some more info..

Malhar Barai
SOA & Java Book
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

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.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: forward() in Servlets
It's not a secret anymore!