wood burning stoves 2.0*
The moose likes Servlets and the fly likes RequestDispatcher's forward method does not work. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "RequestDispatcher Watch "RequestDispatcher New topic
Author

RequestDispatcher's forward method does not work.

pankaj eklar
Greenhorn

Joined: Mar 27, 2008
Posts: 10
Hi,

I am trying to execute following steps in my server side code:

1. I receive a request from GUI requesting for details of an entity.
2. I need these details from an external system, so I put a message on the queue of an external server asking for the details I need.
3. I registered a listener which waits for the response message on a topic.
4. I also store request, response, session and servlet objects in message listener.
5. Current thread does not send the response back to the client and ends.
6. In the onMessage() method, I verify the response and try to forward the response to the client who had requested for it using request dispatcher I get from the stored request object.

After I forward the response, the GUI never received the response back? Call to forward does not throw any exception. Am I doing something that is not allowed or expected?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Yes, you are. Never store references to container objects. They go out of scope as soon as the request completes. You will not be able to handle the operation in the manner that you are doing.

See Ben Souther's example of "Long Running Process" on this page for a better way to deal with it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
pankaj eklar
Greenhorn

Joined: Mar 27, 2008
Posts: 10
It helped. Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RequestDispatcher's forward method does not work.
 
Similar Threads
logout issue
Cant understand the example
JAX-WS Async call
Difference b/w forward and sendRedirect
Http Post