• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is session shared across JSPs in separate web applications?

 
Kishore Kumar Reddy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi



I have a jsp(say,one.jsp) and it requests another jsp(say,two.jsp).From here, it is redirected to another jsp(say,three.jsp and this is in another web application.) one.jsp and two.jsp both are in another web application. and all together are in same web server(Tomcat).

The problem is, I inserted a value in session object in one.jsp. I am trying to retrieve this value from three.jsp.I am unable to get this value.

How can I get this value.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. Sessions are not shared across web applications.

If they need to be this closely tied, why are they separate web apps?

[I adjusted the title of this topic to better represent the question.]
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't we attach that object to a request object, and internally redirect it to the different web application in the same server?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the point of attaching a scoped variable to the request if you are about to do a redirect which cause the current request to terminate?
 
Kishore Kumar Reddy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How data can be shared between different web-applications?

For this, I felt a solution.That is data(for example,userID) sent to another web-app, append this data value as query string while redirecting to anothe web-app.

response.sendRedirect("/anotherWeb-App/recepient.jsp?queryString=userID");

In recepient.jsp, use request.getParameter("userID").

Is it the right solution?
Are there any better solution?
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct Bear! I'm wrong there! Thanks!

And, Kishore Kumar Reddy, with your method, we can only send String. What about other objects?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again I ask, if they need to share data to this extent, is designing them as separate web apps the appropriate design?
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Again I ask, if they need to share data to this extent, is designing them as separate web apps the appropriate design?

So, there are no way to do this?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"no way to do this?"

Not with a session object as managed by the server but there are plenty of ways to share information between web applications.

For example - serialized object with a unique ID stored in a data base or on disk.

Bill

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:"no way to do this?"

Not with a session object as managed by the server but there are plenty of ways to share information between web applications.

For example - serialized object with a unique ID stored in a data base or on disk.

Bill



Thanks, and it is possible only with the shared database?
 
Paul Clapham
Sheriff
Posts: 21152
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abimaran Kugathasan wrote:Thanks, and it is possible only with the shared database?


The two applications have to share data in some way. It doesn't specifically have to be an SQL database.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
The two applications have to share data in some way. It doesn't specifically have to be an SQL database.


I got it, thanks!
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on how much data, and how sensitive the data is, a simple solution might be to use the javax.servlet.http.Cookie object. You may need to have to make the cookie work site wide (as opposed to just under the current directory or context).

I would only do this for a small amount of non-sensitive data. if you have a lot of data, or it contains sensitive information, I'd also advocate the single web application idea that several commentators have already hit on.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic