Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Can sendRedirect method hit a different server instance?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please explain your question in more detail. I really have no idea what you are asking.
 
Soniya Chavan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry I did not elaborate.

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.
 
Soniya Chavan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to pass any information as request parameters on the URL.
 
Soniya Chavan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for the reply.
Can I use the encodeRedirectURL method before sendRedirect to save the session parameters ??
 
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this perhaps an indication that your web apps are constructed incorrectly? Why the need to communicate between them?
 
Paul Clapham
Marshal
Posts: 27211
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Soniya Chavan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ??
 
Bear Bibeault
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are there multiple instances? And why does data need to be shared among them?

 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic