Please find my struts-config.xml file below
<?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="myForm" type="com.fms.clientweb.resources.LoginForm"/>
</form-beans>
<!-- Global Exceptions -->
<global-exceptions>
</global-exceptions>
<!-- Global Forwards -->
<global-forwards>
<forward name="homePage" path="/homePage.do" />
</global-forwards>
<!-- Action Mappings -->
<action-mappings>
<action path="/homePage" name="myForm" type="org.apache.struts.actions.ForwardAction" parameter=".logon" />
<action path="/logon" type="com.fms.clientweb.actions.LogonAction">
<forward name="success" path=".logonSuccess"></forward>
<forward name="failure" path=".logon"></forward>
</action>
</action-mappings>
<!-- Message Resources -->
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"></controller>
<message-resources parameter="com.fms.clientweb.resources.ApplicationResources"/>
<plug-in className="org.apache.struts.tiles.TilesPlugin">
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
<set-property property="moduleAware" value="true" />
</plug-in>
</struts-config>
My Action Class:
package com.fms.clientweb.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.fms.clientweb.forms.LoginForm;
import bd.FMSBusinessDelegate;
/**
* @version 1.0
* @author
*/
public class LogonAction extends Action {
/**
* Constructor
*/
public LogonAction() {
super();
}
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("Entered the Execute menthod in logon action" );
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward();
try {
LoginForm loginForm = (LoginForm) form;
String name = loginForm.getName();
String pass= loginForm.getPassword();
/* String name = request.getParameter("uname");
String pass = request.getParameter("pwd");*/
System.out.println("the value of the userid is" +name);
System.out.println("the value of the password is" +pass);
// test call to the database
FMSBusinessDelegate bd = new FMSBusinessDelegate();
bd.testDb();
//LDAP Authentication
if ( bd.ldapAuthentication(name,pass)) {
forward = mapping.findForward("success");
} else {
forward = mapping.findForward("failure");
}
} catch (Exception e) {
// Report the error using the appropriate name and ID.
errors.add("name", new ActionError("id"));
forward = mapping.findForward("failure");
}
// If a message is required, save the specified key(s)
// into the request for use by the <struts:errors> tag.
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
System.out.println("end of execute method in actionform class" );
return (forward);
}
}
My Jsp:
<%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<h1 class="page_title">File Management System</h1>
<html:form action="logon.do">
<table>
<tr>
<td>
<h3 >Sign in</h3>
</td>
<td>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<h3 >User ID:</h3>
</td>
<td>
<h3><html:text styleClass="text" property="name" /> </h3>
</td>
</tr>
<tr>
<td></td>
<td>
<h3 >Password:</h3>
</td>
<td>
<h3><html:text styleClass="password" property="password"/></h3>
</td>
</tr>
<br></br>
<tr>
<td></td>
<td></td>
<td ><div style="display:none" name="myspan"><font color="red">Please enter the valid username and password</font></div></td>
</tr>
<tr>
<td></td>
<td></td>
<td>
<h3><html:submit property="Submit" value="Submit" /></h3>
</td>
</tr>
</table>
</html:form>