Magazine
 
Integrating JSF, Spring and Hibernate
 

3. Copy spring.jar from spring-framework- 2.0.5-with-dependencies\spring-framework- 2.0.5\dist directory into lib directory of your application.

Now all the libraries are available with us in our application, we will now create database and tables in MySQL to use in our application.

5. Setup MySQL Database

In this section, we will create database and table into MySQL database. Table created here will be used in sample application. Downloading and Installing MySQL
You can download MySQL from mysql.org.

Creating Database:
You can create mysql database by issuing the
following command:
Mysql>create database jsf_hibenate;

Creating Table:

To create table in this database you would have to first select the database by use statement.

Mysql>use jsf_hibenate

Now, you can create table using the following
command:

mysql>create table users (
userId int(11) NOT NULL auto_increment,
userName varchar(20) default NULL,
userPassword varchar(11) default NULL,
userEmail varchar(30) default NULL,
userAddress varchar(30) default NULL,
PRIMARY KEY (userId)
) ;

6. User Login and Registration application Creation of Pages:

This is the first page that appears to the user. In this page user is asked to fill the user name and password to login itself in the site. Both the fields are required to fill. If the user leaves it blank then the message indicating that these

 

can’t be left empty is shown.

Login Page:

login.jsp : The code for above page is given below. For this page CheckValidUser backing bean has been used. On the submission of the page checkUser() method
of the bean is called to check the existence of the user. If the user is registered then user is welcomed to the next page otherwise a message that either user name or password is incorrect.

<%@ taglib uri=”http://java.sun.com/jsf/
html” prefix=”h”%>
<%@ taglib uri=”http://java.sun.com/jsf/
core” prefix=”f”%>
<%@ taglib uri=”http://myfaces.apache.org/
tomahawk” prefix=”t”%>
<f:view>
<html>
<meta http-equiv=”Content-Type”
content=”text/html; charset=iso-8859-1">
<head>
<title>User Login</title>
<link href=”pages/mycss.css”
rel=”stylesheet” type=”text/css”/>
</head>
<body ><center>
<h:panelGrid width=”100%” columns=”1"

Jan 2008 | Java Jazz Up | 59
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

83, 84 , 85 , 86, 87 , 88, 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 , 102 , 103, 104 , 105 ,

106, 107,

Download PDF