This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I've written a struts application which I've split into a number of modules, i.e user, account etc.
I want to have a login form on the home page (within default module) to allow the user to login, however all the user management actions e.g createUserAction, loginAction, logoffAction and corresponding forms are defined in another module in the struts-config-user.xml config file.
I've created a home.jsp page which contains a form, using the html:form and html:text tags, and have included the necessary taglibs.
I have set the form action to "/user/login", which corresponds to the "/login" action within the struts-config-user.xml.
However when I run the application I'm getting the following error :-
javax.servlet.jsp.JspException: Cannot retrieve mapping for action /user/login at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:810) at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506) at org.apache.jsp.Home_jsp._jspx_meth_html_form_0(org.apache.jsp.Home_jsp:169) at org.apache.jsp.Home_jsp._jspx_meth_html_html_0(org.apache.jsp.Home_jsp:124)
which seems to imply that the jsp page can not see the action mapping defined in a different module.
Therefore is it possible to use an action in a different module from the default module. If not is there any way I could replicate this functionality by duplicating the form bean?
where Mod is the module you want to switch to, and page is the jsp or action you want to go to inside that module.
You should be able to specify the above URL in your form's action parameter.
Steve [ November 02, 2005: Message edited by: Steve McCann ]
Joined: Nov 01, 2005
The problem was not in fact the switching of the module, but rather the html:form tag lookup! The FormTag does a lookup for the action and the form bean, and as the action is in a diffent module config file the lookup was failing.
I've changed the form on the login page to use HTML form syntax, instead of the html:form tag, and used the SwitchAction as you described.