Servlet for only forwarded requests

I would like to pass some requests from my first servlet (A) to the second one (B) using RequestDispatcher. And the question is: how can I check if request in B servlet comes from A forwarding and handle only these requests?

preguntado el 31 de julio de 12 a las 09:07

2 Respuestas

In A, puede set an attribute in the request, which you can then read in B.

Respondido 31 Jul 12, 09:07

If the purpose of Servlet B is to only handle requests coming from Servlet A, then you would be better off writing a simple Java class that does what you need, and then returns details that you can use in Servlet A to decide what to do next.

It's possible to use another Servlet for the additional functionality, but is not clean design.

Respondido 31 Jul 12, 09:07

Both servlets have special functions and I can't resign from any of them. - pawb4r

Who wrote both Servlets? If the B shouldn't be called/used from anywhere else other than A, then why can't you refactor B to be a simple class? - Rajesh J Advani

First one is asynchronous spring servlet, the second one - com.sun.jersey.spi.container.servlet.ServletContainer. - pawb4r

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.