forward to servlets running in another context

how can i forward a request from one servlet to another where as the two servlet are running in two different contexts.Message was edited by: Rajvardhan
[173 byte] By [Rajvardhana] at [2007-10-3 1:33:26]
# 1
You can't since contexts are different.Forward will not work in different contexts.You will need to use response.sendRedirect(....) , but request will not get forwarded.You may use URL rewriting during redirect.
RohitKumara at 2007-7-14 18:31:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

thanks for the answer,

In case if my destination context is runing in the same containe/server then can i get the handler to the new context and get the RequestDispatcher using the hanler.

will the above thing work.

if my destination context is not in the same server/container then i can use the sendRedirect to redirect the req ,res to the new active resource.

please correct me if iam wrong.

Message was edited by:

Rajvardhan

Rajvardhana at 2007-7-14 18:31:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

> if my destination context is not in the same server/container then i can use the sendRedirect to redirect the req ,res to the new active resource.

No, a redirect creates a new request. There is no way to send the same request to a different context. You'll have to handle the request in context A, get the fields from the request that need to be sent to context B and then send them along with a redirect. You could use an instant form submit or pass them as url parameters.

gimbal2a at 2007-7-14 18:31:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Ya i totally agree but the whole process is done in the back ground i.e transperant to the user.

what I meant was that with in the same server/container i can use forward but if i want to call any resource installed in another server then we cant achieve this with forward ,the only option available in this situation is sendRedirect.

Is this ok.

Message was edited by:

Rajvardhan

Rajvardhana at 2007-7-14 18:31:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
YES U got it right.
RohitKumara at 2007-7-14 18:31:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...