Meaningless Drivel is fun!
The moose likes Struts and the fly likes Re-entrance into ActionClass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Re-entrance into ActionClass" Watch "Re-entrance into ActionClass" New topic

Re-entrance into ActionClass

Harish Verma
Ranch Hand

Joined: Feb 27, 2006
Posts: 32
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:


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

The struts-config.xml for this

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


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

The struts-config.xml for LoginAction:

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

<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" />

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.

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Re-entrance into ActionClass
It's not a secret anymore!