Registration Form Using Struts Hibernate

First add capabilities of Struts and hibernate Then:-.

<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" ""> <!-- 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>

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

Transaction. import import import import org. SessionFactory" label="name"></s:textfield> <s:textfield name="r.hibernate.close().dtd"> <! package mypack.hibernate. org.hibernate. Session session=f. t.Session.buildSessionFactory(). session.openSession(). public class DAO { public void insert(Object o) { Configuration cfg=new Configuration(). org. <hibernate-mapping> <class name=" Transaction t=session. 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.0' encoding='UTF-8'?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.xml <?xml version='1. } } index. session.hibernate.password" label="password"></s:textfield> .0//EN" "http://hibernate.commit().SessionFactory.Configuration.jsp <%@ taglib uri="/struts-tags" prefix="s"%> <s:form action="Reg"> <s:textfield name=" by MyEclipse Hibernate Tools.

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

Sign up to vote on this title
UsefulNot useful