File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Re-entrance into ActionClass" Watch "Re-entrance into ActionClass" New topic
Author

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:

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

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.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Re-entrance into ActionClass
 
Similar Threads
forward action
Not getting bean values inside IE, In firefox working fine
problems with action mapping
Struts Without Form Bean
Internal Server Error :Cannot find ActionMappings or ActionFormBeans collection