You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Diego Ezquerro <d....@yahoo.com> on 2007/08/17 23:02:49 UTC

Losing Session attributes

Hi to everyone.

I have a problem with the session attributes in my struts app.
I have a login page that checks the username and the password and if it's all right, it fills the session (in the action bean) with an attributte "username" with the username introduced. The app redirects to another page.

When i try to obtain the username attributte in the next page, it is seted to null. I have searched the web and found no answer.

I hanven't invalidated the session and don't know why this is happening.

If anybody knows a possible reason, please tell me.
 
Diego Ezquerro Bailac
Asturias, Spain



__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Re: Losing Session attributes

Posted by Shardul Bhatt <sh...@gmail.com>.
Hi Laurie,

The JSESSIONID is being appended to the URL, but what I noticed is that the
URL displayed at the bottom of the browser when I hover over the button that
opens the pop-up has a wrong action in the URL.

Say it should ideally have
http://localhost:8080/VWS/surveyorLookUp.do;jsessionid=123456.... - Correct

Instead it has http://localhost:8080/VWS/submitJob.do;jsessionid=123456....
--Incorrect

Now, the submitJob.do is the action which is called when the page is
submitted and I move to the next page. But then, the Incorrect URL does open
the pop-up without any errors....just that the list I am looking for is
empty because I get the session attribute as 'null'.

Below is the code which I use to open the popup...


<html:link href="#" onclick="window.open('./surveyorLookup.do',
'TeamMembers', 'width=300, height=300')">
</html:link>


Maybe it is the '#' that causes the wrong URL to be displayed, but then the
pop-up does open. Also, the attribute I get from the session is null.

Any idea what might be going wrong?

Regards,
Shardul.



Laurie Harper wrote:
> 
> If you have cookies disabled, the most likely explanation would be that 
> the URL you use to open the pop-up is not correctly encoded; make sure 
> it includes the jsessionid. If that's not the problem, try posting the 
> JSP and/or Javascript code responsible for opening the 'faulty' page.
> 
> L.
> 
> Shardul Bhatt wrote:
>> Hi All,
>> 
>> I am facing a similar problem. I am using Struts 1.2.
>> 
>> I am setting session attributes in an Action -- say Action A. Then I move
>> to
>> the next page and on this page I open a pop-up which calls another Action 
>> -- say Action B.
>> 
>> Now, when I try to access the attributes set by Action A in Action B, I
>> get
>> 'null'. 
>> 
>> I simply set the attributes as request.getSession().setAttribute("a", A);
>> in
>> Action A. 
>> 
>> I try to retrieve the attributes like
>> request.getSession().getAttribute("a"); in Action B.
>> 
>> I have cookies disabled and this is because of a client requirement.
>> 
>> This session thing works on all the other pages but fails at the above
>> mentioned instance.
>> 
>> Struts config for
>> 
>> Action A
>> 
>> <action path="/submitJob"
>> 			type="net.xxx.clients.xxx.xxx.view.actions.JobAction"
>> 			name="JobForm" input="/jsp/jobType.jsp" validate="true"
>> 			scope="request">
>> 			<forward name="success" path="/jsp/jobDetails.jsp" />
>> 			<forward name="failure" path="/jsp/jobType.jsp" />
>> </action>
>> 
>> Action B
>> 
>> <action path="/surveyorLookup"
>> 			type="net.xxx.clients.xxx.xxx.view.actions.SearchTeamMemberAction"
>> 			name="JobForm" input="/jsp/search.jsp" validate="true"
>> scope="request">
>> 			<forward name="success" path="/jsp/searchSurveyor.jsp" />
>> 			<forward name="failure" path="/jsp/error.jsp" />
>> 		</action>
>> 
>> As you can notice, both the actions are sharing the same form, I think it
>> should be possible to retrieve the 
>> values set in the form in Action A, by Action B. Even in this case the
>> values I get are null.
>> 
>> Can anybody help me please? Thanks in advance.
>> Shardul. 
>> 
>> 
>> 
>> strutstwouser wrote:
>>> Are u using Struts 1.x or 2 ? -- please paste the code from struts xml
>>> and how you are doing the redirect? ; will attempt to answer after
>>> that.
>>>
>>> -Joseph
>>>
>>> On 8/17/07, Paul Benedict <pb...@apache.org> wrote:
>>>> If you switch domains or ports, you will lose your session. Sessions
>>>> are
>>>> usually tied to cookies which have these restrictions.
>>>>
>>>> On 8/17/07, Diego Ezquerro <d....@yahoo.com> wrote:
>>>>> Hi to everyone.
>>>>>
>>>>> I have a problem with the session attributes in my struts app.
>>>>> I have a login page that checks the username and the password and if
>>>> it's
>>>>> all right, it fills the session (in the action bean) with an
>>>>> attributte
>>>>> "username" with the username introduced. The app redirects to another
>>>> page.
>>>>> When i try to obtain the username attributte in the next page, it is
>>>> seted
>>>>> to null. I have searched the web and found no answer.
>>>>>
>>>>> I hanven't invalidated the session and don't know why this is
>>>> happening.
>>>>> If anybody knows a possible reason, please tell me.
>>>>>
>>>>> Diego Ezquerro Bailac
>>>>> Asturias, Spain
>>>>>
>>>>>
>>>>>
>>>>> __________________________________________________
>>>>> Correo Yahoo!
>>>>> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
>>>>> Regístrate ya - http://correo.espanol.yahoo.com/
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Losing-Session-attributes-tf4288159.html#a12231458
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Losing Session attributes

Posted by Laurie Harper <la...@holoweb.net>.
If you have cookies disabled, the most likely explanation would be that 
the URL you use to open the pop-up is not correctly encoded; make sure 
it includes the jsessionid. If that's not the problem, try posting the 
JSP and/or Javascript code responsible for opening the 'faulty' page.

L.

Shardul Bhatt wrote:
> Hi All,
> 
> I am facing a similar problem. I am using Struts 1.2.
> 
> I am setting session attributes in an Action -- say Action A. Then I move to
> the next page and on this page I open a pop-up which calls another Action 
> -- say Action B.
> 
> Now, when I try to access the attributes set by Action A in Action B, I get
> 'null'. 
> 
> I simply set the attributes as request.getSession().setAttribute("a", A); in
> Action A. 
> 
> I try to retrieve the attributes like
> request.getSession().getAttribute("a"); in Action B.
> 
> I have cookies disabled and this is because of a client requirement.
> 
> This session thing works on all the other pages but fails at the above
> mentioned instance.
> 
> Struts config for
> 
> Action A
> 
> <action path="/submitJob"
> 			type="net.xxx.clients.xxx.xxx.view.actions.JobAction"
> 			name="JobForm" input="/jsp/jobType.jsp" validate="true"
> 			scope="request">
> 			<forward name="success" path="/jsp/jobDetails.jsp" />
> 			<forward name="failure" path="/jsp/jobType.jsp" />
> </action>
> 
> Action B
> 
> <action path="/surveyorLookup"
> 			type="net.xxx.clients.xxx.xxx.view.actions.SearchTeamMemberAction"
> 			name="JobForm" input="/jsp/search.jsp" validate="true" scope="request">
> 			<forward name="success" path="/jsp/searchSurveyor.jsp" />
> 			<forward name="failure" path="/jsp/error.jsp" />
> 		</action>
> 
> As you can notice, both the actions are sharing the same form, I think it
> should be possible to retrieve the 
> values set in the form in Action A, by Action B. Even in this case the
> values I get are null.
> 
> Can anybody help me please? Thanks in advance.
> Shardul. 
> 
> 
> 
> strutstwouser wrote:
>> Are u using Struts 1.x or 2 ? -- please paste the code from struts xml
>> and how you are doing the redirect? ; will attempt to answer after
>> that.
>>
>> -Joseph
>>
>> On 8/17/07, Paul Benedict <pb...@apache.org> wrote:
>>> If you switch domains or ports, you will lose your session. Sessions are
>>> usually tied to cookies which have these restrictions.
>>>
>>> On 8/17/07, Diego Ezquerro <d....@yahoo.com> wrote:
>>>> Hi to everyone.
>>>>
>>>> I have a problem with the session attributes in my struts app.
>>>> I have a login page that checks the username and the password and if
>>> it's
>>>> all right, it fills the session (in the action bean) with an attributte
>>>> "username" with the username introduced. The app redirects to another
>>> page.
>>>> When i try to obtain the username attributte in the next page, it is
>>> seted
>>>> to null. I have searched the web and found no answer.
>>>>
>>>> I hanven't invalidated the session and don't know why this is
>>> happening.
>>>> If anybody knows a possible reason, please tell me.
>>>>
>>>> Diego Ezquerro Bailac
>>>> Asturias, Spain
>>>>
>>>>
>>>>
>>>> __________________________________________________
>>>> Correo Yahoo!
>>>> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
>>>> Regístrate ya - http://correo.espanol.yahoo.com/
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Losing Session attributes

Posted by Shardul Bhatt <sh...@gmail.com>.
Hi All,

I am facing a similar problem. I am using Struts 1.2.

I am setting session attributes in an Action -- say Action A. Then I move to
the next page and on this page I open a pop-up which calls another Action 
-- say Action B.

Now, when I try to access the attributes set by Action A in Action B, I get
'null'. 

I simply set the attributes as request.getSession().setAttribute("a", A); in
Action A. 

I try to retrieve the attributes like
request.getSession().getAttribute("a"); in Action B.

I have cookies disabled and this is because of a client requirement.

This session thing works on all the other pages but fails at the above
mentioned instance.

Struts config for

Action A

<action path="/submitJob"
			type="net.xxx.clients.xxx.xxx.view.actions.JobAction"
			name="JobForm" input="/jsp/jobType.jsp" validate="true"
			scope="request">
			<forward name="success" path="/jsp/jobDetails.jsp" />
			<forward name="failure" path="/jsp/jobType.jsp" />
</action>

Action B

<action path="/surveyorLookup"
			type="net.xxx.clients.xxx.xxx.view.actions.SearchTeamMemberAction"
			name="JobForm" input="/jsp/search.jsp" validate="true" scope="request">
			<forward name="success" path="/jsp/searchSurveyor.jsp" />
			<forward name="failure" path="/jsp/error.jsp" />
		</action>

As you can notice, both the actions are sharing the same form, I think it
should be possible to retrieve the 
values set in the form in Action A, by Action B. Even in this case the
values I get are null.

Can anybody help me please? Thanks in advance.
Shardul. 



strutstwouser wrote:
> 
> Are u using Struts 1.x or 2 ? -- please paste the code from struts xml
> and how you are doing the redirect? ; will attempt to answer after
> that.
> 
> -Joseph
> 
> On 8/17/07, Paul Benedict <pb...@apache.org> wrote:
>> If you switch domains or ports, you will lose your session. Sessions are
>> usually tied to cookies which have these restrictions.
>>
>> On 8/17/07, Diego Ezquerro <d....@yahoo.com> wrote:
>> >
>> > Hi to everyone.
>> >
>> > I have a problem with the session attributes in my struts app.
>> > I have a login page that checks the username and the password and if
>> it's
>> > all right, it fills the session (in the action bean) with an attributte
>> > "username" with the username introduced. The app redirects to another
>> page.
>> >
>> > When i try to obtain the username attributte in the next page, it is
>> seted
>> > to null. I have searched the web and found no answer.
>> >
>> > I hanven't invalidated the session and don't know why this is
>> happening.
>> >
>> > If anybody knows a possible reason, please tell me.
>> >
>> > Diego Ezquerro Bailac
>> > Asturias, Spain
>> >
>> >
>> >
>> > __________________________________________________
>> > Correo Yahoo!
>> > Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
>> > Regístrate ya - http://correo.espanol.yahoo.com/
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Losing-Session-attributes-tf4288159.html#a12230607
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Losing Session attributes

Posted by j alex <st...@gmail.com>.
Are u using Struts 1.x or 2 ? -- please paste the code from struts xml
and how you are doing the redirect? ; will attempt to answer after
that.

-Joseph

On 8/17/07, Paul Benedict <pb...@apache.org> wrote:
> If you switch domains or ports, you will lose your session. Sessions are
> usually tied to cookies which have these restrictions.
>
> On 8/17/07, Diego Ezquerro <d....@yahoo.com> wrote:
> >
> > Hi to everyone.
> >
> > I have a problem with the session attributes in my struts app.
> > I have a login page that checks the username and the password and if it's
> > all right, it fills the session (in the action bean) with an attributte
> > "username" with the username introduced. The app redirects to another page.
> >
> > When i try to obtain the username attributte in the next page, it is seted
> > to null. I have searched the web and found no answer.
> >
> > I hanven't invalidated the session and don't know why this is happening.
> >
> > If anybody knows a possible reason, please tell me.
> >
> > Diego Ezquerro Bailac
> > Asturias, Spain
> >
> >
> >
> > __________________________________________________
> > Correo Yahoo!
> > Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> > Regístrate ya - http://correo.espanol.yahoo.com/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Losing Session attributes

Posted by Paul Benedict <pb...@apache.org>.
If you switch domains or ports, you will lose your session. Sessions are
usually tied to cookies which have these restrictions.

On 8/17/07, Diego Ezquerro <d....@yahoo.com> wrote:
>
> Hi to everyone.
>
> I have a problem with the session attributes in my struts app.
> I have a login page that checks the username and the password and if it's
> all right, it fills the session (in the action bean) with an attributte
> "username" with the username introduced. The app redirects to another page.
>
> When i try to obtain the username attributte in the next page, it is seted
> to null. I have searched the web and found no answer.
>
> I hanven't invalidated the session and don't know why this is happening.
>
> If anybody knows a possible reason, please tell me.
>
> Diego Ezquerro Bailac
> Asturias, Spain
>
>
>
> __________________________________________________
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> Regístrate ya - http://correo.espanol.yahoo.com/