Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Re-entrance into ActionClass

 
Harish Verma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a strange problem: when I want to show a page, the control instead comes in again and again to the action class, and finally the debugger dies, probably due to stack overflow.

1. user logs out.
2. Clicks 'Back' on browser, and reaches a transaction page (I am curently not interested in page expiry/invalidation techniques).
3. Clicks a link.

What I want is:

- User should be taken back to login page, which is fronted by LoginAction.

Relevant code below:

In XYZaction.java:

if (!(s.isValidUser(request)))
{
forward = mapping.findForward("InitLogin");
return forward;
}

The struts-config.xml for this XYZaction.java:

<global-forwards type="org.apache.struts.action.ActionForward">
<forward name="InitLogin" path="/Login.do" />
</global-forwards>

In LoginAction.java:

if (request.getParameter("DISPATCH") == null ||
request.getParameter("DISPATCH").toString().equalsIgnoreCase("InitLogin"))
{
//A fresh login request.
forward = mapping.findForward("InitLogin");
return forward;
}

The struts-config.xml for LoginAction:

<form-beans>
<form-bean name="LoginForm" type="org.rbi.rpcd.login.beans.LoginForm"/>
</form-beans>

<action path="/Login" type="org.rbi.rpcd.login.actionclass.LoginAction" name="LoginForm">
<forward name="ChangePwd" path="/../common/T_CHANGE_PASS.jsp" />
<forward name="InitLogin" path="/../common/T_LOGIN.jsp" />
</action>

From XYZAction, the control reaches LoginAction properly. But then, what happens is that though the forward InitLogin points to a JSP, the LoginAction actionclass is entered again (instead of the page showing up), and this is happening over and over again. Please help me out of this conundrum.

TIA.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Within InitLogin Action, you have defined a global forward and a local forward both named "InitLogin". What is apparently happening is that it's finding the global forward which points back again to the action class and that puts it into an endless loop.

The solution is to name your local forward something else besides "InitLogin" (e.g. localInitLogin) and have the InitLogin action forward to localInitLogin rather than InitLogin.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic