I need to the session information in the target jsp. Is is possible that the sendRedirect method can hit the target jsp on another instance of the server??
What will be the alternative method in this case id I need to make sure that the same server instance is being hit??
I am using sendRedirect method to forward the request from source to another jsp (target.jsp). In the target.jsp I need to access the session parameters.
Now these jsp's are a part of my application which is deployed on 2 instances of the server.Since sendRedirect makes a new request and sendRedirect can be used to forward to resources not within the same context. Is it possible that the source and the target may not reside on the same server instance?? and that the sendRedirect can forward the request to target.jsp of another server instance.
Joined: May 10, 2010
And if the target.jsp of another server instance (not the same server instance of the source) is being hit....The target.jsp will not have the session parameters.
Really, if your application is running on more than one server, and sessions aren't being shared among those servers, there is no point in using sessions at all. You would have to pass the relevant information around as request parameters, like Bear suggested.
It sounds to me like there's only one application, and there is more than one instance of it running on more than one server. And that sessions aren't being shared among the servers. I would definitely describe that as "constructed incorrectly" and I would work on getting that fixed rather than trying to work around it with programming.
But it's possible I am misunderstanding the background to the question.
Joined: May 10, 2010
First of all thanks a lot Paul and Bear.
Yes Paul you are right.There is a single application but more than one instance of the application.So the best way to solve this problem is to share the session among all the instances ??
Soniya Chavan wrote:First of all thanks a lot Paul and Bear.
So the best way to solve this problem is to share the session among all the instances ??
Session replication is one solution.
Another would be to use sticky sessions at the router/load balancer (probably the simplest if your router can do this).
Another would be to make the instances stateless (no session data).
The 'best' solution depends on a lot of things.
Folks on a web forum are probably not in the best determination to make that call for you.
The solution is depends upon the setup of our instances,
1. if the instances are in clustering with session replication, no need of any fix from code, hitting any of the instances will not make any differences
2. if the instances are not in clustered session replication and the redirection of the requests are happening from a load balancer, usually only the first request from the client will hit loadbalancer and the subsequent requests and redirect will hit the same instance, its like loadbalancer is doing one time redirecting to one instance.
3. if the instance are not in clustered session replication and the redirection is happening from a load balancer for every request, then this setup need to be fixed not the program.
subject: Can sendRedirect method hit a different server instance?