Could you kindly help me regarding this issue.
I have a login jsp which accepts username and password.
The login.jsp feeds a bean. The action class takes values from the bean and if
password is equal to " password " it goes to Success.jsp through action forward.
My issue is when I call the page i.e login.do then
it goes directly to action class without showing the login.jsp page.
It then gives me null pointer exception.
------------------------------------------------------|||||||||
LOGIN.JSP
--------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<html:html>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<TITLE></TITLE>
</HEAD>
<body bgcolor="white">
<html:form action="/login" method="post" ;">
<center>
<table width="400" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table border="0" cellspacing="2" cellpadding="1" width="100%" >
<tr bgcolor="#eaeac8">
<td align="left" colspan="2"><font size="5">User Login</font></td>
</tr>
<tr><td colspan="2"><p> </p></td></tr>
<tr align="center">
<td align="right">User ID:</td>
<td><html:text property="username" size="30" maxlength="30"/></td>
</tr>
<tr align="center">
<td align="right">Password:</td>
<td><html
assword property="password" size="30" maxlength="30"/></td>
</tr>
<tr><td colspan="2"><p> </p></td></tr>
<tr>
<TD>Login Now !<html:submit property="submit" value="Submit" /></TD>
</tr>
</table>
</td>
</tr>
</table>
</center>
</html:form>
<body>
</html:html>
LOGINACTION
-----------------
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LOGINACTION extends {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
LOGINFORM loginform = (LOGINFORM) form;
if (loginform.getPassword().equals("password")
&& (loginform.getPassword() != null)) {
ActionForward forward = null;
return mapping.findForward("success");
else {
return mapping.findForward("failure");
}
}
}
STRUTCONFIG
--------------
<action path="/LOGIN"
type="COM.LOGINACTION"name="LOGINFORM" scope="request" validate="true"
input="/jsps/LOGIN.jsp">
<forward name="success" path="/jsps/LOGIN/Success.jsp" />
<forward name="success" path="/jsps/LOGIN/Failture.jsp" />
</action>
FORMBEAN
----------------
<form-bean name="LOGINFORM"
type="LOGIN.LOGINFORM">
------------------------------------------------------------||||||||
Any help would be greatly appreciated.