Developing Registration Application in JSF

 Developing Registration Application

Screenshot_11

 

Index.html

<html>

<head>

<meta http equiv=”Refest”name=”Generater”content=”2,url=http://localhost:1010/requestion app/registration form.dss”>

</head>

<body>

<br><br>

<center>

<font size=”6”color=”red”>

Application is loading

</font>

</center>

</ body >

</html>

  

 

Registration form.jsp

<% @tag lib url=http://JAVA.SUN.COM/JSF/CARE”Prefix=f”%>

/html” Prefix=”h”%>

<f:view>

<html>

<body>

<font color=”red”>

<h1> software solutions</h1>

<h2>student Registration form</h2>

</font>

<h:form>

<h:panel grid column=”2”bg color=”Light blur”>

<h:out put text value=”student id”/>

<h:in put text id=”sid” value=”#{student id}”/>

<h:out put text value=”student name”/>

<h:in put text id=”s name” value=”#{student Bean.sname}”/>

<h:out put text value=”student mail”/>

<h:in put text id=”se mail” value=”#{student Bean.se mail }”/>

<h:out put text value=”student mobile”/>

<h:in put text id=”smobile ” value=”#{student Bean. smobile }”/>

<h:command button value=”ADD”action==”#{student Bean. add }”/>

<h:panelGrid>

</h:from>

</body>

</html>

</f:view>

 

Existed.html

<%@ taglib------------------- “f”%>

<%                                                                                  “h”%>

</f:view>

<html>

<body bgcolor=”Light yellow”>

<br>< br >

<center>

<b><font size=”6”color=”red”>

Student already existed.

</font>

</b>

</center>

</body>

</html>

</f:view>

 

Success.jsp

<%@taglib-------->

<%@taglib-------->

<f:view>

<html>

<body bgcolor=”light yellow”>

<font size=”6”color=”green”>

Student registered successfully..

</font>

</body></html></f:view>

 

Failure.jsp

<%@tag----

<% ----

<f:view>

<html>

<body bgcolor=”red”>

<font size=”8”color=”green”>

Student registration failed—

</font>

</body>

</html></t:view>

 

Student Bean.java

Package com. soft;

Public class student bean{

Private string sid:

Private string sname;

Private string semail;

Private string smobile;

Set—()               //provide setter and getter()

Getter—()

Student action sa=new studentAction();

String status =sa. Addstudent(sid,sname,semail,smobile);

Return status;

}

}

 

Student action.java

Package com. soft;

Import java.sql.*;

Public class studentAction

{

String status=””;

Public string add student(string sid, string sname string email, string smobile)

{

Type{

Connection con=jdbcultil. get connection();

Prepared statement pst=con. prepared statement(“select* from student where sid=?”);

Pst.set string (1,sid);

Resultset ms=pst execute query();

Boolern b=ms.next();

If()b==true)

{

Status=”existed”;

}

Else{

Pst=con. Prepare statement(“insert into student values(????)”);

Pst. setstring(1,sid);

Pst. setstring(2,sname);

Pst. setstring(3,semail);

Pst. setstring(4,smobile);

Pst. Execute update();

Status=”Success”;

}

}

Catch(exception()

{

Status=”failure”;

e.print stack ace ()

}

Return status;

}

}

 

Jdbcutil.java

Package com.durgasoft;

Import java.sql*;

Public class Jdbcutil

{

Static connection con;

Static

{

Try

{

Class. fore name(“oracle. jdbc. oracle drivet”);

Con=Driver manager. Get connection(“jdbc:oracle; thin:@local host:1521: oricle”,”scot”,”tiger”);

}

Catch(exception)

{

e.printstacture();

}

}

Public static connection get connection()

{

Return com;

}

}

 

Faces-config.xml

<facs.config=xsd>

<managed. bean>

<managed. Bean.name>student bean</managed-bean-name>

<managed. Bean. class>com. soft. student bean</managed-bean- class >

<managed. Bean. scope>session</managed-bean- scope >

<managed. Bean>

<navigation. rule>

<from-view-id>/registrationfrom.jsp</from-view-id>

<navigation-case>

<from-outcome >success<</from –outcome>

<to-view-id>/success.jsp</ to view-id>

</navigation. case>

<from-outcome>success</from-outcome>

<to-view-id> /success.jsp</to-view-id>

</navigation. case>

<navigation. case>

<from-outcome>failure</from-outcome>

<to-view-id> / failure.jsp</to-view-id>

</navigation. case>

<navigation. case>

<from-outcome>failure</from-outcome>

<to-view-id> / existed.jsp</to-view-id>

</navigation. case>

</navigation. rule>

</faces. config>

 

Web.xml

<web-app>

<servlet>

<servlet-name>faces servlet</servlet-name>

<servlet-class>Javax. faces. webapp. faces servlet< /servlef-class >

<load-on-startup>1</ load-on-startup >

<servlet>

<servlet-mapping>

<servlet-name> faces servlet< servlet-name>

<url-pattern>*.dss<url-pattern>

<servlet-mapping>

</web-app>