|
Home > Archive > EAserver > December 2005 > Share sessions variables across web applications
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Share sessions variables across web applications
|
|
| Daniel Coppersmith 2005-11-19, 8:24 pm |
| Hi!
Is it possible for me to share a session variable across a web application?
For example, let's say in:
http://myhost/AAA/blah.jsp
I set session variable "HELLO" to "World"
Then on that page, I get redirected to the web page:
http://myhost/BBB/yada.jsp
I want to get "HELLO" and have it return to me "World".
Is this possible? Seems like when I "cross over" to another web app, I lose
my session variables for that web app (but they are still there in the web
app they were set in).
Thanks,
D
| |
| Carson Hager 2005-11-20, 3:23 am |
| No it's not.
Carson
____________________
____________________
____
Carson Hager
Cynergy Systems, Inc.
http://www.cynergysystems.com
Email: carson. hager@cynergysystems
.com
Office: 866-CYNERGY ext. 89
Mobile: 1.703.489.6466
Take PowerBuilder to the Web with EAF 4.0
http://www.cynergysystems.com/public/products/eaf
"Daniel Coppersmith" <daniel_N.0.S.P.A. M_at_InFrontSoftware
_D0T_C0M> wrote
in message news:437fb201$1@foru
ms-2-dub...
> Hi!
>
> Is it possible for me to share a session variable across a web
> application?
>
> For example, let's say in:
>
> http://myhost/AAA/blah.jsp
>
> I set session variable "HELLO" to "World"
>
> Then on that page, I get redirected to the web page:
> http://myhost/BBB/yada.jsp
>
> I want to get "HELLO" and have it return to me "World".
>
> Is this possible? Seems like when I "cross over" to another web app, I
> lose
> my session variables for that web app (but they are still there in the web
> app they were set in).
>
> Thanks,
>
> D
>
>
| |
| Jonathan Baker [Sybase] 2005-11-30, 3:24 am |
| That's not possible, because J2EE says you can't do that. It would
violate security or something like that.
I use a different approach - use a DB table to store temporary data that
both web applications can read. If you store it on something like user
name, each app logged in with the same user name should have access.
Jonathan
Daniel Coppersmith wrote:
> Hi!
>
> Is it possible for me to share a session variable across a web application?
>
> For example, let's say in:
>
> http://myhost/AAA/blah.jsp
>
> I set session variable "HELLO" to "World"
>
> Then on that page, I get redirected to the web page:
> http://myhost/BBB/yada.jsp
>
> I want to get "HELLO" and have it return to me "World".
>
> Is this possible? Seems like when I "cross over" to another web app, I lose
> my session variables for that web app (but they are still there in the web
> app they were set in).
>
> Thanks,
>
> D
>
>
| |
| Alexander Pire 2005-12-01, 3:24 am |
| You could use something like this:
JSP1:
<%
application.setAttribute("HELLO","World");
%>
JSP2:
<%
String myVar = (String) application.getAttribute("HELLO");
%>
In a Servlet you have to do this:
ServletContext application = getServletContext();
The information is saved in the JVM scope. But remember this is not a
SESSION object, this is an Application Object
Regards
Alexander Pire
PowerObjects
www.powerobjects.com
612.339.3355
**IT Solutions - Outside the Box**
"Daniel Coppersmith" <daniel_N.0.S.P.A. M_at_InFrontSoftware
_D0T_C0M> wrote
in message news:437fb201$1@foru
ms-2-dub...
> Hi!
>
> Is it possible for me to share a session variable across a web
> application?
>
> For example, let's say in:
>
> http://myhost/AAA/blah.jsp
>
> I set session variable "HELLO" to "World"
>
> Then on that page, I get redirected to the web page:
> http://myhost/BBB/yada.jsp
>
> I want to get "HELLO" and have it return to me "World".
>
> Is this possible? Seems like when I "cross over" to another web app, I
> lose
> my session variables for that web app (but they are still there in the web
> app they were set in).
>
> Thanks,
>
> D
>
>
| |
| Alexander Pire 2005-12-01, 3:24 am |
| One more think Daniel,
You asked if it is possible for you to share a session variable across a web
application.
My example will work in your web application, but your links looks like you
are using two differents Web Applications
http://myhost/AAA/blah.jsp
http://myhost/BBB/yada.jsp
If this is the case I recommend you to use the DataBase methods (like
Jhonatan recommend you before)
Let me know if we solved your problem.
Regards
Alexander Pire
PowerObjects
www.powerobjects.com
612.339.3355
**IT Solutions - Outside the Box**
"Alexander Pire" < Alexander_no_spam_@p
owerobjects_dot_com> wrote in message
news:438e98d5$1@foru
ms-1-dub...
> You could use something like this:
> JSP1:
> <%
> application.setAttribute("HELLO","World");
> %>
>
> JSP2:
> <%
> String myVar = (String) application.getAttribute("HELLO");
> %>
>
> In a Servlet you have to do this:
> ServletContext application = getServletContext();
>
> The information is saved in the JVM scope. But remember this is not a
> SESSION object, this is an Application Object
>
> Regards
> Alexander Pire
> PowerObjects
> www.powerobjects.com
> 612.339.3355
> **IT Solutions - Outside the Box**
>
> "Daniel Coppersmith" <daniel_N.0.S.P.A. M_at_InFrontSoftware
_D0T_C0M> wrote
> in message news:437fb201$1@foru
ms-2-dub...
>
>
| |
| Carson Hager 2005-12-01, 1:24 pm |
| This will hardly help someone who's trying to store user session
information. All users share the same data using the approach you describe
here.
Carson
____________________
____________________
____
Carson Hager
Cynergy Systems, Inc.
http://www.cynergysystems.com
Email: carson. hager@cynergysystems
.com
Office: 866-CYNERGY
Mobile: 1.703.489.6466
Take PowerBuilder to the Web with EAF 4.0
http://www.cynergysystems.com/public/products/eaf
"Alexander Pire" < Alexander_no_spam_@p
owerobjects_dot_com> wrote in message
news:438e98d5$1@foru
ms-1-dub...
> You could use something like this:
> JSP1:
> <%
> application.setAttribute("HELLO","World");
> %>
>
> JSP2:
> <%
> String myVar = (String) application.getAttribute("HELLO");
> %>
>
> In a Servlet you have to do this:
> ServletContext application = getServletContext();
>
> The information is saved in the JVM scope. But remember this is not a
> SESSION object, this is an Application Object
>
> Regards
> Alexander Pire
> PowerObjects
> www.powerobjects.com
> 612.339.3355
> **IT Solutions - Outside the Box**
>
> "Daniel Coppersmith" <daniel_N.0.S.P.A. M_at_InFrontSoftware
_D0T_C0M> wrote
> in message news:437fb201$1@foru
ms-2-dub...
>
>
| |
| Alexander Pire 2005-12-01, 8:25 pm |
|
Carson, I put this comment at the end of my last mail:
"But remember this is not a SESSION object, this is an
Application Object"
Probably you didn't read it, I'm pretty sure you know the
difference between Session object an Application Object:
Daniel I found this site to you have some examples and a
pretty cool definition about Session objects, Application
Objects and Request Atrributes.
http://www.gulland.com/courses/Java...sp_objects3.jsp
Best Regards
Alexander Pire
PowerObjects
www.powerobjects.com
612.339.3355
**IT Solutions - Outside the Box**
> This will hardly help someone who's trying to store user
> session information. All users share the same data using
> the approach you describe here.
>
>
> Carson
>
> ____________________
____________________
____
>
> Carson Hager
> Cynergy Systems, Inc.
> http://www.cynergysystems.com
>
> Email: carson. hager@cynergysystems
.com
> Office: 866-CYNERGY
> Mobile: 1.703.489.6466
>
> Take PowerBuilder to the Web with EAF 4.0
> http://www.cynergysystems.com/public/products/eaf
>
>
> "Alexander Pire" < Alexander_no_spam_@p
owerobjects_dot_com>
> wrote in message news:438e98d5$1@foru
ms-1-dub...
> Object >
> in message news:437fb201$1@foru
ms-2-dub... >> Hi!
> across a web >> application?
> another web app, I >> lose
> still there in the >> web
>
>
|
|
|
|
|