This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Struts and the fly likes action mapping problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "action mapping problem" Watch "action mapping problem" New topic

action mapping problem

priya web

Joined: Sep 29, 2006
Posts: 2
I have the following mapping in my struts-config file. The page shows the login page (which has the actual login form) and this action mapping works. Since I am using validation, it also displays required errors for username and password back on the page. However when all the form fields are entered correctly it show me a blank page.

The problem is the other mapping which calls LoginAction does not work. There are no errors shown in the server logs.. I have a print statement inside the LoginAction on the very first line of the execute() method but it does not print anything. I am assuming that it does not reach LoginAction. I am not sure what I am doing wrong because I dont see any errors. Can anyone please help me?

<!-- Form Bean Definitions -->
<form-bean name="loginForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="userName" type="java.lang.String">
<form-property name="password" type="java.lang.String">
<!-- Action Mapping Definitions -->
<action path="/login" type="edu.test.action.LoginAction" name="loginForm"
scope="request" validate="true" input="/WEB-INF/jsp/login.jsp">
<forward name="success" path="/WEB-INF/jsp/login-success.jsp"></forward>
<action path="/showLogin" forward="/WEB-INF/jsp/login.jsp">

Here is my LoginAction code

public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletRequest response)
throws Exception {
System.out.println("In action");
return mapping.findForward("success");
} }

Here is my login.jsp file

<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<TABLE><html:form action="/login" method="post">
<TR><TD>Username:</TD><TD><html:text property="userName" /></TD></TR>
<TR><TD>Password:</TD><TD><html assword property="password" ></TD>
<TR><TD>Submit</TD><TD><html:submit value="Login"/> </TD></TR>
[ October 10, 2006: Message edited by: Bear Bibeault ]
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
What's the mapping you have done for struts in web.xml? Usually the form will have some suffix like /

Just a question: Are you sure you are able to see the Login.jsp which is inside WEB-INF folder?
[ September 29, 2006: Message edited by: Purushothaman Thambu ]
priya web

Joined: Sep 29, 2006
Posts: 2
This is my web.xml file

Usually the form will have some suffix like /
My form has /login and I have *.do in ActionServlet.. I tried doing a / also for the form in the login page and it makes no difference

>Just a question: Are you sure you are able to see the Login.jsp which is >inside WEB-INF folder?
Yes because I have mapped it
<action path="/showLogin" forward="/WEB-INF/jsp/login.jsp">

Since I have used validation framework, the validation works on the login page and it says missing username etc.. but when everything is correct it does not go to the LoginAction. I have a print statement inside action but it doesnt work. I am using Struts 1.2.9...
Raji Balakrishnan

Joined: Jan 19, 2005
Posts: 5
Hi Priya,

Where you able to solve the problem? I am also facing the same problem. Let me know if you find any solution to fix it
sajan chandran chandran

Joined: Oct 10, 2006
Posts: 2
Hi Priya..

Am also not sure what the problem is.But try change and see the <load-on-startup>-1</load-on-startup> instead of -1 try to put any number greater than zero.

sure nandu

Joined: Oct 16, 2006
Posts: 18
Hi Priya,

i copied your all files and tried to execute. it was showing the same problem.

then there was error in your Action class. In your execute method you have given fourth paramater as HttpServletRequest. it has to be HttpServletResponse. change it and it will work.
I agree. Here's the link:
subject: action mapping problem
It's not a secret anymore!