feed.jsp print("<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body bgcolor="pink"> <form action="./Thanks.jsp"> Enter name: <input type="text" name="name"/> <br/> </br> Mobile number:<input type="text" name="mob"/><br/><br/> Email address:<input type="text" name="email"/> <br/></br> Quality of information <input type="radio" name="quality" value="Good"/> Good<input type="radio" name="quality" value="Average"/> Average <input type="radio" name="quality" value="Poor"/> Poor <br/><br/> Amount of information <input type="radio" name="amount" value="Good"/> Good<input type="radio" name="amount" value="Average"/> Average <input type="radio" name="amount" value="Poor"/> Poor <br/> <br/> Any suggestion? <textarea name="suggestion" ></textarea> <br/> <br/><br/> <input type="submit" name="submit" value="Submit"/> </form> </body> </html>"); Thanks.jsp print("<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.util.List"%> <%@ page import="p1.saveCustomer"%> <%@ page import="p1.mycustomer" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body bgcolor="sky blue"> <font color="white" size="30"> Thank you <%=request.getParameter("name")%> <jsp:useBean id="f1" class="p1.mycustomer" scope="page"> </jsp:useBean> <jsp:setProperty name="f1" property="*"/> <% saveCustomer.getDetails(f1); %> </font> </body> </html>"); hibernate.cfg.xml print("<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd" > <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver-class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql:localhost:3306/test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.hbm2ddl.auto">create</property> <mapping package="p1" resource="p1.mycustomer.hbm.xml"/> </session-factory> </hibernate-configuration>"); All the files below are under src/ package p1. mycustomer.java print("package p1; public class mycustomer { String name,email,quality,amount,suggestion; int mob; public mycustomer(String name, String email, String quality, String amount, String suggestion, int mob) { super(); this.name = name; this.email = email; this.quality = quality; this.amount = amount; this.suggestion = suggestion; this.mob = mob; } public mycustomer() { super(); // TODO Auto-generated constructor stub } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getQuality() { return quality; } public void setQuality(String quality) { this.quality = quality; } public String getAmount() { return amount; } public void setAmount(String amount) { this.amount = amount; } public String getSuggestion() { return suggestion; } public void setSuggestion(String suggestion) { this.suggestion = suggestion; } public int getMob() { return mob; } public void setMob(int mob) { this.mob = mob; } } "); saveCustomer.java print("package p1; import java.util.List; import org.apache.catalina.Session; import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class saveCustomer { List<mycustomer> l=null; public static void getDetails(mycustomer mc) { SessionFactory sf=new Configuration().configure().buildSessionFactory(); org.hibernate.Session s=sf.openSession(); Transaction t=s.beginTransaction(); //Query q=s.createQuery("from mycustomer"); //q.setCacheable(true); //l=q.list(); //s.getTransaction().commit(); t.begin(); int i=(Integer)s.save(mc); t.commit(); s.close(); } } "); mycustomer.hbm.xml print("<?xml version="1.0" encoding="UTF-8"?> <hibernate-mapping> <class name="p1.mycustomer" table="fedback_data"> <composite-id name="name" type="varchar2" column="Name"> <generator class="native"/> </composite-id> <property name="mob"> <column name="mobile"/> </property> <property name="email"> <column name="email"/> </property> <property name="quality"> <column name="Q"/> </property> <property name="amount"> <column name="A"/> </property> <property name="suggestion"> <column name="s"/> </property> </class> </hibernate-mapping>"); exception org.apache.jasper.JasperException: org.hibernate.MappingNotFoundException: resource: p1.mycustomer.hbm.xml not found org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Ads