struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Milan Milanovic <milanmilanov...@yahoo.com>
Subject Re: [Struts 2] Session scope
Date Thu, 29 May 2008 15:50:57 GMT
I see now that execute method is not called at all, it seems that Struts 2 is creating some
cache of the pages! I make link like this:

<a href="<s:url action="wizard.action" namespace="/wizard" />">Enter Wizard</a>

when user click on this, page is shown but execute method is not invoked, but all of the combo
boxes in page are populated and this is done in the execute method. Here is my mapping from
struts.xml for this:

<package name="wizard" namespace="/wizard" extends="struts-default">
    <action name="wizard" method="execute" class="wizardAction">
            <result>/pages/wizard/firstPage.jsp</result>
            <result name="input">/pages/wizard/firstPage.jsp</result>
    </action>
</package>

Of course action class is linked using spring:

<bean id="wizardAction" scope="prototype"
        class="com.myproject.actions.WizardAction">
        <constructor-arg ref="wizardService" />
</bean>

What's the problem here ?!

--
Thx, Milan

Milan Milanovic <milanmilanovich@yahoo.com> wrote: I think that I found problem. When
user click on the contents page to enter wizard page 1., execute method is called to pre-populate
this page, and later he enter page 2. But when he again go to contents page and click wizard
button link to enter page 1. (new) execute method is not fired at all ?! And if he doesn't
click refresh execute method is not fired and all of the data is keep in session.

--
Thx, Milan Milanovic

Milan Milanovic  wrote: No, actually this error is not related to session it is some exeption
related to my model class. Here is session log when called from two methods:

17:26:28,265  WARN com.actions.WizardAction:108 - SESSION_EXECUTE: {ACEGI_SECURITY_LAST_USERNAME=milan,
ACEGI_SECURITY_CONTEXT=org.acegisecurity.context.SecurityContextImpl@16e285e: Authentication:
org.acegisecurity.providers.UsernamePasswordAuthenticationToken@16e285e: Username: org.acegisecurity.userdetails.User@75a9e00:
Username: milan; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired:
true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN; Password: [PROTECTED]; Authenticated:
true; Details: org.acegisecurity.ui.WebAuthenticationDetails@ffff6a82: RemoteIpAddress: 127.0.0.1;
SessionId: 2F81EE5600F9EC5BE8E487DBE6E6153A; Granted Authorities: ROLE_ADMIN}

17:26:46,406  WARN com.actions.WizardAction:215 - SESSION_SAVE:    {ACEGI_SECURITY_LAST_USERNAME=milan,
fruits=[Fruit id=null date=Thu May 29 00:00:00 CEST 2008 number=1 weight=2.0 calories=3.0
price=null], fruit=Fruit id=null from=Mon May 12 00:00:00 CEST 2008 to=Thu May 29 00:00:00
CEST 2008, ACEGI_SECURITY_CONTEXT=org.acegisecurity.context.SecurityContextImpl@16e285e: Authentication:
org.acegisecurity.providers.UsernamePasswordAuthenticationToken@16e285e: Username: org.acegisecurity.userdetails.User@75a9e00:
Username: milan; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired:
true; AccountNonLocked: true; Granted Authorities: ROLE_ADMIN; Password: [PROTECTED]; Authenticated:
true; Details: org.acegisecurity.ui.WebAuthenticationDetails@ffff6a82: RemoteIpAddress: 127.0.0.1;
SessionId: 2F81EE5600F9EC5BE8E487DBE6E6153A; Granted Authorities: ROLE_ADMIN}


Milan Milanovic  wrote: It is wierd, I implemented the simplest SessionAware pattern, and
when I call logger.info("SESSION: " + getSession()); from my execute method it writes it,
but when I call the same logger.info code from my method which is invoked when user click
on the submit button on the second wizard page I got an exeption:

java.lang.NullPointerException
at java.util.AbstractList.hashCode(Unknown Source)
    at org.apache.struts2.dispatcher.SessionMap$1.hashCode(SessionMap.java:125)
    at java.util.HashMap.put(Unknown Source)
    at java.util.HashSet.add(Unknown Source)
    at org.apache.struts2.dispatcher.SessionMap.entrySet(SessionMap.java:117)
    at java.util.AbstractMap.toString(Unknown Source)
    at java.lang.String.valueOf(Unknown Source)
    at java.lang.StringBuilder.append(Unknown Source)
at com.actions.WizardAction.save(WizardAction.java:215)
...

?

--
Thx, Milan

Juan Pablo Pizarro  wrote: Sorry, I supposed that the problem is the same.

Bye.

2008/5/29, Milan Milanovic :
> Is started this thread and then Juan Pablo Pizarro asked his questions. I'm not sure
if we have the same problem.
>
> --
> Milan
>
> Dave Newton  wrote: I'm confused; are there two people with identical problems or am
I
> thread-challenged today?
>
> --- Milan Milanovic  wrote:
>
> > Hi Dave,
> >
> > >There is only one session per conversation. If you're using the same
> > >session (i.e., same browser window/tab, etc.) then there shouldn't
> > be
> > >any issues.
> >
> > I'm using the same browser and tab, I'm just testing application by
> > using links in it (without logging out).
> >
> > >I'd focus first on your implementation logic. You can also check the
> > >session ID to make sure they're the same session--if they're not,
> > >something's wrong.
> >
> > O.K. I'll check this.
> >
> > --
> > Thx, Milan
> >
> > Dave Newton  wrote: There is only one session
> > per conversation. If you're using the same
> > session (i.e., same browser window/tab, etc.) then there shouldn't be
> > any issues.
> >
> > I'd focus first on your implementation logic. You can also check the
> > session ID to make sure they're the same session--if they're not,
> > something's wrong.
> >
> > Dave
> >
> > --- Milan Milanovic  wrote:
> >
> > > Should my action class implement SessionAware  ?
> > >
> > > Milan Milanovic  wrote: Hi Martin,
> > >
> > > thank you.
> > >
> > > My action package extends="struts-default", does this mean when I
> > > call
> > > ActionContext.getContext().getSession() that I doesn't have access
> > to
> > > session ?
> > >
> > > It seems to me that every  creates a new session for my action
> > class,
> > > and at least two methods doesn't have access to the same session.
> > How
> > > can I manage to share my variable through multiple jsp pages for
> > one
> > > action class using the users session ?
> > >
> > > --
> > > Thx, Milan
> > >
> > > Martin  wrote: Hello Milan-
> > >
> > > You can accomplish creation of HttpSession via
> > > CreateSessionInterceptor
> > >
> >
> http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/interceptor/CreateSessionInterceptor.html
> > >
> > > (session parameters are available via a map which is is available
> > > via)
> > > ActionContext.getContext().getSession()
> > >
> > > If you would be amenable to using a IOC container I would look at
> > > implementing Springs SessionContextAutowiringInterceptor
> > >
> >
> http://www.opensymphony.com/webwork/api/com/opensymphony/webwork/spring/interceptor/SessionContextAutowiringInterceptor.html
> > >
> > > HTH
> > > Martin
> > >
> > > ----- Original Message -----
> > > From: "Milan Milanovic"
> > > To: "Struts Users Mailing List"
> > > Sent: Wednesday, May 28, 2008 11:08 AM
> > > Subject: Re: [Struts 2] Session scope
> > >
> > >
> > > > It seems that every request have its own scope ?!
> > > >
> > > > Milan Milanovic  wrote: Hi,
> > > >
> > > > I have one action class and two pages. When first page is called,
> > > in its
> > > > execute method I remove my session variable, like this:
> > > >
> > > > ServletActionContext.getContext().getSession().remove("fruits");
> > > >
> > > > and then when form from the first jsp page is submitted user
> > enter
> > > details
> > > > in the second form and there I save those changed to session,
> > too:
> > > >
> > > > ServletActionContext.getContext().getSession().put("fruits",
> > > fruits);
> > > >
> > > > Of course, I first check if there is already fruits in session. I
> > > do this
> > > > because some maybe want to go to first page to change something
> > and
> > > then
> > > > to go again to the second page to continue entering other info.
> > > But, when
> > > > I exit both page an execute method is called (with above session
> > > remove
> > > > method), and my second page is called fruits from session are
> > read
> > > again -
> > > > they are not removed ?
> > > >
> > > > --
> > > > Thx in advance, Milan Milanovic
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
>
>

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



       

       

       

       
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message