Illegal Argument Exception
Hello,
This is Anupam Sarkar from Kolkata of India.I am developing a demo Struts Application in which I am facing a problem.I am mailing the .config file and the Action Form and Action Class and the exception message that I am getting.
Config File
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- Data Sources -->
<data-sources>
</data-sources>
<!-- Form Beans -->
<form-beans>
<form-bean name="loginForm" type="com.wipro.actionform.LoginForm">
</form-bean>
</form-beans>
<!-- Global Exceptions -->
<global-exceptions>
</global-exceptions>
<!-- Global Forwards -->
<global-forwards>
</global-forwards>
<!-- Action Mappings -->
<action-mappings>
<action path="/login" type="com.wipro.actionclass.LoginAction" input="/index.jsp" name="loginForm" scope="request" validate="true">
<exception type="com.wipro.exception.UserNameException" key="error.userName" path="/index.jsp"/>
<exception type="com.wipro.exception.PasswordException" key="error.password" path="/index.jsp"/>
<forward name="login" path="/login.jsp"></forward>
</action>
</action-mappings>
<!-- Message Resources -->
<message-resources parameter="com.wipro.resources.ApplicationResources"/>
</struts-config>
Action Class
package com.wipro.actionclass;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.wipro.actionform.LoginForm;
import com.wipro.exception.PasswordException;
import com.wipro.exception.UserNameException;
public class LoginAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse res) throws Exception {
// TODO Auto-generated method stub
LoginForm logForm=(LoginForm)form;
if(logForm.getUserName().equals("anupam"))
{
if(!logForm.getPassword().equals("sarkar"))
{
throw new PasswordException();
}
}
else
{
throw new UserNameException();
}
return new ActionForward("login");
}
}
ActionForm
package com.wipro.actionform;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class LoginForm extends ActionForm {
/**
*
*/
private static final long serialVersionUID = 1L;
private String userName=null;
private String password=null;
private ActionErrors acErrors=null;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
acErrors=new ActionErrors();
if(userName.length()==0)
{
acErrors.add(userName,new ActionError("error.userName.blank"));
}
if(password.length()==0)
{
acErrors.add(password,new ActionError("error.password.blank"));
}
return acErrors;
}
}
The first page is opening(index.jsp).But as Enter the Login Credential and pressing the submit Button I am getting Exception
The Exception taht I am getting is
java.lang.IllegalArgumentException: Path login does not start with a "/" character
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1062)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor .java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Plz Help me out.
Thanks in Advanced
Anupam Sarkar

