Registration Form Using Struts Hibernate

First add capabilities of Struts and hibernate Then:-.

hibernate.cfg.xml
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. <hibernate-configuration> -->

<session-factory> <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property> <property name="connection.username">system</property> <property name="connection.password">system</property> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property> <mapping resource="Registration.hbm.xml"/> </session-factory> </hibernate-configuration>

Registration.java

this.name = name. public Registration() { super().password = password.id = id. } public void setEmail(String email) { this. } public String getName() { return name.package mypack.email. String password. } public void setPassword(String password) { this.name = name. } public String getPassword() { return password. this.password = password. this.password.email = email. } public Registration(String name. } public void setId(int id) { this. public class Registration { int id. } public void setName(String name) { this. String email) { super(). } public String getEmail() { return email. String name.email = email. } public int getId() { return id. } } .

import import import import org.sourceforge. SessionFactory f=cfg.Registration. t.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <s:form action="Reg"> <s:textfield name="r.close().0' encoding='UTF-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3. org.java package mypack. } } index.0//EN" "http://hibernate.hibernate.buildSessionFactory(). org.Registration"> <id name="id" type="int"> <generator class="increment"></generator> </id> <property name="name"/> <property name="password"/> <property name="email"/> </class> </hibernate-mapping> --> DAO.save(o).hbm.hibernate.Transaction.xml <?xml version='1.name" label="name"></s:textfield> .Generated by MyEclipse Hibernate Tools. session.openSession(). <hibernate-mapping> <class name="mypack. public class DAO { public void insert(Object o) { Configuration cfg=new Configuration().cfg. org.hibernate. session.dtd"> <!-. Transaction t=session.Configuration.configure().commit().hibernate.SessionFactory. Session session=f.beginTransaction().Session.0.net/hibernate-mapping-3.

0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.java package mypack.jsp</result> </action> </package> </struts> RegistrationAction. } } . dao. } public Registration getR() { return r.xml <?xml version="1.1//EN" "http://struts. return "success".insert(r).password" label="password"></s:textfield> <s:textfield name="r. } public void setR(Registration r) { this.r = r.email" label="email"></s:textfield> <s:submit value="register"></s:submit> </s:form> a.jsp <b>successfully inserted</b> Struts. public class RegistrationAction { Registration r.<s:textfield name="r.apache.dtd"> <struts> <package name="demo" extends="struts-default"> <action name="Reg" class="mypack.org/dtds/struts-2. public String execute() { DAO dao=new DAO().RegistrationAction"> <result name="success">/a.1.

Sign up to vote on this title
UsefulNot useful