Wednesday 27 July 2016

IMAGE UPLOADING IN DATABASE USING HIBERNATE

Step 1:  Create Database


CREATE TABLE `upload_image` (`IMAGE` longblob NULL DEFAULT NULL )

Step 2: Create persistent class

import java.sql.Blob;

public class pojo {
private  Blob image;

public Blob getImage() {
return image;
}

public void setImage(Blob image) {
this.image = image;
}}


Step 3: Create cfg and hbm xml files


hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.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.password">root</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <mapping resource="pojo.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

pojo.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jul 27, 2016 4:54:07 PM by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
    <class name="pojo" table="POJO">
        <id name="image" type="java.sql.Blob">
            <column name="IMAGE" />
            <generator class="assigned" />
        </id>
    </class>
</hibernate-mapping>


hibernate.reveng.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>
  <table-filter match-catalog="test" match-name="upload_image"/>
</hibernate-reverse-engineering>


Step 4: Create Action class

uploadingServlet.java

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.io.File;
import java.io.FileInputStream;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
@WebServlet("/uploadServlet")
@MultipartConfig(maxFileSize = 1216584)    // upload file's size up to 16MB
public class uploadServlet extends HttpServlet {
     
protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
       
        InputStream inputStream = null; // input stream of the upload file
         
        // obtains the upload file part in this multipart request
        Part filePart = request.getPart("photo");
        if (filePart != null) {
            // prints out some information for debugging
            System.out.println(filePart.getName());
            System.out.println(filePart.getSize());
            System.out.println(filePart.getContentType());
             
            // obtains input stream of the upload file
            inputStream = filePart.getInputStream();
        }
         
      try {
           
        //creating configuration object  
            Configuration cfg=new Configuration();  
            cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file  
              
            //creating session factory object  
            SessionFactory factory=cfg.buildSessionFactory();  
              
            //creating session object  
            Session session=factory.openSession();  
              
            //creating transaction object  
            Transaction t=session.beginTransaction();  
        // constructs SQL statement
            PreparedStatement statement = session.connection().prepareStatement("INSERT INTO upload_image values (?)");
                   
            if (inputStream != null) {
                // fetches input stream of the upload file for the blob column
                statement.setBlob(1, inputStream);
            }
            // sends the statement to the database server
            int row = statement.executeUpdate();
            if (row > 0) {
            t.commit();
                session.close();
                System.out.println("Saved");
                
            System.out.println("File uploaded and saved into database");
            }
        } 
        
        catch (SQLException ex) 
        {
        System.out.println("ERROR: " + ex.getMessage());
            ex.printStackTrace();
        }  }}
       
        




IMAGE UPLOADING IN DATABASE MYSQL USING JSP AND SERVLET

Step 1: Create Database

Step 2: home.jsp

<%@ 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>
<body>
    <center>
        <h1>File Upload to Database</h1>
        <form method="post" action="uploadServlet" enctype="multipart/form-data">
            <table border="0">
               <tr>
                    <td>Portrait Photo: </td>
                    <td><input type="file" name="photo" size="50"/></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" value="Save">
                    </td>
                </tr>
            </table>
        </form>
    </center>
</body>
</html>


uploadServlet.java

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
 
@WebServlet("/uploadServlet")
@MultipartConfig(maxFileSize = 16177215)    // upload file's size up to 16MB
public class uploadServlet extends HttpServlet {
     
    // database connection settings
    private String dbURL = "jdbc:mysql://localhost:3306/test";
    private String dbUser = "root";
    private String dbPass = "root";
     
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
       
        InputStream inputStream = null; // input stream of the upload file
         
        // obtains the upload file part in this multipart request
        Part filePart = request.getPart("photo");
        if (filePart != null) {
            // prints out some information for debugging
            System.out.println(filePart.getName());
            System.out.println(filePart.getSize());
            System.out.println(filePart.getContentType());
             
            // obtains input stream of the upload file
            inputStream = filePart.getInputStream();
        }
         
        Connection conn = null; // connection to the database
        String message = null;  // message will be sent back to client
         
        try {
            // connects to the database
            DriverManager.registerDriver(new com.mysql.jdbc.Driver());
            conn = DriverManager.getConnection(dbURL, dbUser, dbPass);
 
            // constructs SQL statement
            String sql = "INSERT INTO upload_image values (?)";
            PreparedStatement statement = conn.prepareStatement(sql);
          
             
            if (inputStream != null) {
                // fetches input stream of the upload file for the blob column
                statement.setBlob(1, inputStream);
            }
 
            // sends the statement to the database server
            int row = statement.executeUpdate();
            if (row > 0) {
                message = "File uploaded and saved into database";
            }
        } catch (SQLException ex) {
            message = "ERROR: " + ex.getMessage();
            ex.printStackTrace();
        } finally {
            if (conn != null) {
                // closes the database connection
                try {
                    conn.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
            }
           
        }
    }
}


Friday 22 July 2016

IMAGE STORED IN DATABASE USING HIBERNATE

Step 1: Create Database

Create database upload

Create Table

Create table Employee(Id int,Dp image primary key(Id))


Step 2: Create Persistent Class


public class Employee
{
private int id;
private byte[] dp;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public byte[] getDp() {
return dp;
}
public void setDp(byte[] dp) {
this.dp = dp;
}
}

Step 3:Main.java

import java.io.File;
import java.io.FileInputStream;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class Main {
public static void main(String ar[])
{
//creating configuration object  
    Configuration cfg=new Configuration();  
    cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file  
      
    //creating session factory object  
    SessionFactory factory=cfg.buildSessionFactory();  
      
    //creating session object  
    Session session=factory.openSession();  
      
    //creating transaction object  
    Transaction t=session.beginTransaction();  
Employee e=new Employee();
e.setId(1);
File file=new File("C:/Users/Public/Pictures/Sample Pictures/Penguins.jpg");
byte[] bytefile=new byte[(int)file.length()];
try
{
FileInputStream fs=new FileInputStream(file);
fs.read(bytefile);
fs.close();}
catch(Exception ex)
{
System.out.println(ex);
}
e.setDp(bytefile);
session.save(e);
t.commit();//transaction is committed  
        session.close();
System.out.println("success");}}

Step 4:hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
 <property name="hibernate.connection.driver_class">
com.microsoft.sqlserver.jdbc.SQLServerDriver
</property>
        <property name="hibernate.connection.password">Password@12345</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;databaseName=SI
        </property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
        <mapping resource="Employee.hbm.xml"/>
    </session-factory>
</hibernate-configuration>

Step 5: Employee.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jul 22, 2016 12:59:00 PM by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
    <class name="Employee" table="login">
        <id name="id" type="int">
            <column name="ID" />
            <generator class="assigned" />
        </id>
       <property name="dp" column="dp" type="binary" />
    </class>
</hibernate-mapping>


For java.sql.Blob:

<property name="photo" column="PHOTO" type="blob" />

For primitive byte[] array:

<property name="photo" column="PHOTO" type="binary" />





Tuesday 19 July 2016

HIBERNATE AND STORED PROCEDURE

Step 1.Database Creation


       Create database Student;


Step 2.Table Creation


       Create table data(sno int,name varchar(15),email varchar(15));

Step 3.Create Stored Procedure


CREATE PROCEDURE bigdata(@uid int,@uname varchar(15),@uemail varchar(15))
AS
BEGIN
SET NOCOUNT ON
insert into data values(@uid,@uname,@uemail)
SET NOCOUNT OFF
END

Step 4. Create home.jsp


<%@ 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">
<form action="register">
S.No:<input type="text" name="sno">
Name:<input type="text" name="name">
Email:<input type="text" name="email">
<input type="submit" value="submit"> 

Step 5: Create hbm&cfg xml file


hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
  <property name="hibernate.connection.password">Password@12345</property>
 <property
name="hibernate.connection.url">jdbc:sqlserver://localhost:1433;databaseName=Student
</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
        <mapping resource="regi.hbm.xml" />
    </session-factory>
</hibernate-configuration>

login.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jul 19, 2016 4:39:35 PM by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
    <class name="login" table="data">
        <id name="sno" type="int">
            <column name="sno" />
            <generator class="assigned" />
        </id>
        <property name="name" type="java.lang.String">
            <column name="name" />
        </property>
        <property name="email" type="java.lang.String">
            <column name="email" />
        </property>
    </class>
</hibernate-mapping>

login.java

public class login {
private int sno;
private String name,email;
public int getSno() {
return sno;
}
public void setSno(int sno) {
this.sno = sno;
}
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;
}}


register.java

import java.io.IOException;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

@WebServlet("/register")
public class register extends HttpServlet {
private static final long serialVersionUID = 1L;
   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
String sno=request.getParameter("sno");
String name=request.getParameter("name");
String email=request.getParameter("email");
int snoo=Integer.parseInt(sno);
try
{
Configuration cfg=new Configuration();
cfg.configure("hibernate.cfg.xml");
SessionFactory ss=cfg.buildSessionFactory();
Session session=ss.openSession();
Transaction t=session.beginTransaction();
try
{
PreparedStatement st = session.connection().
prepareStatement("{callbigdata(?,?,?)}");
                st.setInt(1, snoo);
st.setString(2, name);
st.setString(3, email);
st.execute();
}
catch(Exception e)
{
e.printStackTrace();
}
t.commit();
session.close();
System.out.println("Saved");
}
catch(HibernateException e)
{
System.out.println(e.getMessage());
System.out.println("ERROR");
}}}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>HiberDemoSP</display-name>
    <servlet>
        <servlet-name>register</servlet-name>
        <servlet-class>register</servlet-class>
    </servlet>
       <servlet-mapping>
        <servlet-name>register</servlet-name>
        <url-pattern>/register</url-pattern>
    </servlet-mapping>
   <welcome-file-list>
        <welcome-file>home.jsp</welcome-file>
  </welcome-file-list>
</web-app>



Thursday 14 July 2016

SQL SERVER WITH JAVA USING NETBEANS

We follow the following steps :


1.Install SQL Server and  Netbeans.
2.We have to put user name and password while sql server installing.
3.Add Required Sqljdbc jar.

For SQL SERVER


Step 1:    create the database and table in Sql Server Management Studio. 

Step 2:     When we open the  Sql Server Management Studio, have to change the Authentication  name in Sql Server Authentication

Step 3:     Type the Login name and password.Suppose you did not mentioned username and password while your installing,Execute the following query 

                        ALTER LOGIN sa WITH PASSWORD='p@*******';

                         ALTER LOGIN sa enable;

Step 4:      Select  SQL Server Configuration Manager

                  Sql server Network Configuration-->protocols for SQLEXPRESS---->TCP/IP--Enable


For NETBEANS

1. Connect the Sql Server in Driver using sqljdbc jar.

home.jsp

<html>
    <head>
        <title>Login</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <form action="Login">
            Name<input type="text" name="name"><br/>
            Email<input type="email" name="email"><br/>
                        <input type="submit" value="Login">
        </form>
    </body>
</html>


Login.java

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Login extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
        String name=request.getParameter("name");
        String email=request.getParameter("email");
        try
        {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;            databaseName=Student","sa","Password@12345");
            Statement st=con.createStatement();
            st.executeUpdate("insert into login values('"+name+"','"+email+"')");
            out.println("inserted"); }
        catch(Exception e)
        {
            System.out.println(e); }  } }}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <servlet>
        <servlet-name>Login</servlet-name>
        <servlet-class>Login</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Login</servlet-name>
        <url-pattern>/Login</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
</web-app>

   







Create the Hibernate Application in Eclipse IDE

We follow following steps to create hibernate application :

  1. Create the Dynamic web project
  2. Add jar files for hibernate
  3. Create the Persistent class
  4. Create the mapping file for Persistent class(.hbm.xml)
  5. Create the Configuration file(.cfg.xml)
  6. Create the class that retrieves or stores the persistent object
  7. Run the application

Step 1: Create the project(New-->Dynamic web project)


Step 2: Add required jar files























Step 3: Create the Persistent Class

Testing.java


package com.java;
public class Testing {
private String name,email,password;
private int amt;
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 getPassword() {return password;}

public void setPassword(String password) {this.password = password;}

public int getAmt() {return amt;}

public void setAmt(int amt) {this.amt = amt;}}


Step 4:Create the mapping and configuration file for persistent class


src-->New-->other--Hibernate-->console configuration file




i)Select Database connection and select the server what we used.here we used MYSQL.Select mysql server 
ii)Select Configuration file and create new





hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.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.password">root</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
         <mapping resource="mypack/testing.hbm.xml"/>
    </session-factory>
</hibernate-configuration>



Step 5: Create Mapping file

Testing.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jul 14, 2016 3:37:00 PM by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
    <class name="com.java.Testing" table="TESTING">
        <id name="name" type="java.lang.String">
            <column name="Name" />
            <generator class="assigned" />
        </id>
        <property name="email" type="java.lang.String">
            <column name="email" />
        </property>
        <property name="password" type="java.lang.String">
            <column name="password" />
        </property>
        <property name="amt" type="int">
            <column name="Amount" />
        </property>
    </class>
</hibernate-mapping>

Step 6: Create the servlet class for store and retrive the persistent object


home.jsp

<%@ 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>Home Page</title>
</head>
<body>
<form action="New">
NAME<input type="text" name="name"/>
PASSWORD<input type="password" name="password"/>
EMAIL<input type="text" name="email"/>
Amount<input type="text" name="amt"/>
<input type="submit" value="Login">
</form>
</body>
</html>


New.java


package com.jeni;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class New extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
       
        String name=request.getParameter("name");
        String email=request.getParameter("email");
        String password=request.getParameter("password");
        String amt1=request.getParameter("amt");
        int amt=Integer.parseInt(amt1);
       
        //creating configuration object  
            Configuration cfg=new Configuration();  
            cfg.configure("hibernate.cfg.xml");//populates the data of the configuration file  
              
            //creating session factory object  
            SessionFactory factory=cfg.buildSessionFactory();  
              
            //creating session object  
            Session session=factory.openSession();  
              
            //creating transaction object  
            Transaction t=session.beginTransaction();  
                  
            Testing e1=new Testing();  
            e1.setName(name);
            e1.setPassword(password);
            e1.setEmail(email); 
            e1.setAmt(amt);
            
            session.persist(e1);//persisting the object  
              
            t.commit();//transaction is committed  
            session.close();  
            out.println("successfully saved");  
             }
        catch(Exception e)
        {
        System.out.println(e);
        }}}

    web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>DynamicH</display-name>
  <servlet>
        <servlet-name>New</servlet-name>
        <servlet-class>com.jeni.New</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>New</servlet-name>
        <url-pattern>/New</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
  <welcome-file-list>
     <welcome-file>home.jsp</welcome-file>
  </welcome-file-list>
</web-app>


//Same as persistent class name,hbm file name and database table