struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daveck <d...@holstein.com>
Subject Losing Session Attributes
Date Tue, 05 Feb 2008 20:24:17 GMT

Hi,
I'm looking for some help, or some input on why I might be losing session
attributes (Not the session itself).

Processing Flow:
quest.action --> quest-input.jsp  -> quest.action --> MyInterceptor -> 
                      confirm.jsp -> question.action --> quest-success.jsp

I am setting session attributes in my interceptor to have available
following the confirm.jsp.

Sometimes the attributes are there and sometimes they're not.  There doesn't
seem to be any rhyme or reason.

Probably something simple I'm overlooking, but if so, I've been overlooking
it for two days!

Thanks!
David


MyInterceptor.java:

    public String intercept (ActionInvocation invocation) throws Exception {

        final ActionContext context = invocation.getInvocationContext();
	    HttpServletRequest request = (HttpServletRequest)
context.get(HTTP_REQUEST);
	    HttpSession session =  request.getSession(true);

        // check if request is coming form the Confirmation Screen
        if ((request.getParameter("CONFIRM_SCREEN") != null) &&
                (request.getParameter("CONFIRM_SCREEN").equals("TRUE"))) {

            String urlGoingTo = invocation.getProxy().getNamespace() +
            invocation.getProxy().getActionName()+".action";

            // save input form attributes to session
            session.setAttribute("PARMS", request.getParameterMap());

            // save the forwarding url for the Confirmation Screen
            session.setAttribute(URL_GOING_TO, urlGoingTo);

            return "confirm";
	    } else {
            return invocation.invoke();
        }
     }


Quest.java:

    public String execute() throws Exception {

        if (this.getSession().containsKey("PARMS")) {
            BeanUtils.populate(this, (Map)this.getSession().get("PARMS"));

            return SUCCESS;

        } else {

            return INPUT;
        }
    }


quest-input.jsp

    <%@ taglib prefix="s" uri="/struts-tags" %>
    <s:head theme="ajax" />
    <link href="<s:url value="/html/body.css"/>" rel="stylesheet"
type="text/css" />

    <s:div id="reg" label="Registration Number" theme="ajax"
            labelposition="top" >

     <s:form action="cowQuest" method="Post" validate="true">
         <s:select
                 name="nation"
                 label="Nation"
                 headerKey="0"
                 list="nationList" />
         <s:textfield name="registrationNumber" label="Registration Number"
size="10"/>
         <s:hidden name="CONFIRM_SCREEN" value="TRUE"/>
         <s:submit value="Click Here to Run" id="submit"/>
     </s:form>

     </s:div>


confirm.jsp
    <%@ taglib prefix="s" uri="/struts-tags"%>
    <link href="<s:url value="/html/body.css"/>" rel="stylesheet"
type="text/css" />

    <h2>Please confirm your request.</h2>
    <br>
    <p>This could take several minutes depending on the request.</p>

    <s:form method="post">
        <s:param name="action" value="quest.action"/>
        <s:submit value="Confirm" align="center">
		    <s:param name="colspan" value="%{2}" />
		    <s:param name="align" value="%{'center'}" />
	    </s:submit>
    </s:form>


struts.xml

     <action name="quest" class="com.helpme.struts.actions.Quest">
         <interceptor-ref name="myInterceptor"/>
         <result name="input">/quest-input.jsp</result>
         <result name="confirm">/confirm.jsp</result>
         <result name="success">/quest-success.jsp</result>
         <result name="error">/quest-error.jsp</result>
     </action>
-- 
View this message in context: http://www.nabble.com/Losing-Session-Attributes-tp15298791p15298791.html
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


Mime
View raw message