Creating Login Page In JSF using NetBeans

Ads
 

Creating Login Page In JSF using NetBeans

This example illustrates you how to create a login form in JSF using NetBeans.

This example illustrates you how to create a login form in JSF using NetBeans.

Creating Login Page In JSF using NetBeans

        

This example illustrates you how to create a login form in JSF using NetBeans. To create the jsp page in NetBeans:

1. Right click on Web Pages under your project.
2. Go to New- JSP and click.
3. Enter JSP File Name (login, for this example) when New JSP File window appear.
4. Click Finish. Then the page will be created and listed as below:

 

Write your code for login. In this example, login.jsp is created. The code is given below:

Source Code of login.jsp

<%-- 
  Document : login
  Created on : Sep 10, 2008, 1:45:52 PM
  Author : sandeep kumar suman
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
 <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Login Page</title>
  </head>
  <body>
  <f:view>
  <h:form id="LoginForm">
  <h:panelGrid id="lpg" columns="2">
  
  <h:outputText value="User ID"/>
  <h:inputText size="25"/>  
  <h:outputText value=""/>
  <h:commandButton value="Login"/>
  
  </h:panelGrid>
  </h:form>
  </f:view>
 </body>
</html>

 

Description of all tags which is used in this program:

<f: view>
  tag is used to create top level view and is a container for all JSF component tags on a page.
<h:form> tag creates html form.
<h:panelGrid> tag creates html table with specified number of columns.
<h:outputText> tag is used for creating component for displaying formatted output as text.
<h:inputText> tag is used to creates  text input control (single line).

Run the program just by right click on login.jsp page and select run. The following output will be displayed on browser:


Download Source Code

Ads

Tutorials   

Ads