<jsp:forward page="login.jsf" />
Here is the code of the login.jsp:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:view>
<html>
<head>
<title>Remember Me Login Application</title>
</head>
<body>
<div align="left">
<h:form id="frm" onsubmit="return initialize();">
<table height="250" border="1" cellpadding="3" cellspacing="1">
<tr>
<td valign="top"><br/><br/>
<table>
<tr>
<td><h:outputText value="User Name: "
/></td>
<td><h:inputText id="username" value
="#{RememberMeLogin.username}" /></td>
</tr>
<tr>
<td><h:outputText value="Password: "
/></td>
<td><h:inputSecret id="password"
value="#{RememberMeLogin.password}"
required="true" redisplay="true" /></td>
</tr>
<tr>
<td> </td>
<td><h:commandButton value="Login"
action="#{RememberMeLogin.CheckLogin}" onclick="initialize" /></td>
</tr>
<tr>
<td> </td>
<td><h:selectBooleanCheckbox id=
"remember" value="#{RememberMeLogin.remember}"
onclick="return check(this);" />
<h:outputLabel for="remember">Remember
Me</h:outputLabel></td>
</tr>
</table>
</td>
</tr>
</table>
</h:form>
</div>
</body>
</html>
</f:view>
|
Here is the code of the RememberMeLogin.java file which is the bean class:
package roseindia;
|
Here is the code of the web.xml file:
<?xml version="1.0"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//
EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app> |
Here is the code of the faces-config.xml file:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" "http://java.sun.com/dtd/web-facesconfig_1_0.dtd"> <faces-config> <managed-bean> <managed-bean-name>RememberMeLogin</managed-bean-name> <managed-bean-class>roseindia.RememberMeLogin </managed-bean-
class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/login.jsp</from-view-id>
<navigation-case>
<from-action>#{RememberMeLogin.CheckLogin}
</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/success.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{RememberMeLogin.CheckLogin}
</from-action>
<from-outcome>failure</from-outcome>
<to-view-id>/failure.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
|
Here is the output for the whole example:

Download this complete source code of the example.
|
Recommend the tutorial |

Ask Questions? Discuss: Remember Me Login Application In JSF View All Comments
Post your Comment