• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is session shared across JSPs in separate web applications?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
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 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.]
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
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
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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28226
95
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

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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic