These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]

Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: The requested resource (/EmServl.do) is not available. ---
PostPosted: Mon Jun 16, 2014 11:25 am 

Joined: Mon Jun 16, 2014 11:19 am
Posts: 1
I am trying to build a simple form and i'm using only hibernate.
plz help me out
i'm getting this error

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Employee Registry</title>
<h1>Employee Registration</h1>
<form action="/EmServl.do" method="post">
<table cellpadding="3pt" border=0>
<td>First Name</td>
<td><input type="text" size="30" name="First"/></td>
<td>Last Name</td>
<td><input type="text" size="30" name="Last"/></td>
<td><input type="text" size="30" name="Position"/></td>
<td><input type="text" size="30" name="Salary"/></td>

<table cellpadding="3pt" border=0>
<td><input type="submit" value="Add"/></td>




package com.tut.hibernate.buildclass;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

private static final SessionFactory sessionfactory;

static {
try {
sessionfactory = new Configuration().configure().buildSessionFactory();

}catch (Throwable ex){
System.err.println("Initial Session Factory Creation failed" +ex);
throw new ExceptionInInitializerError(ex);


public static SessionFactory getSessionFactory() {
return sessionfactory;





package com.tut.hibernate.modelclass;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.TableGenerator;

public class Employee {

@TableGenerator(initialValue=1 ,name="de", allocationSize=1)
@GeneratedValue(strategy = GenerationType.TABLE,generator = "de")
private int employeeID;
private String firstName, lastName, position, salary;

public int getEmployeeID() {
return employeeID;
public void setEmployeeID(int employeeID) {
this.employeeID = employeeID;
public String getFirstName() {
return firstName;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getLastName() {
return lastName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getPosition() {
return position;
public void setPosition(String position) {
this.position = position;
public String getSalary() {
return salary;
public void setSalary(String salary) {
this.salary = salary;




<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hiber</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">jithern</property>
<property name="hbm2ddl.auto">create </property>
<property name="show_sql">true</property>
<mapping class="com.tut.hibernate.modelclass.Employee" />



package com.tut.hibernate.saveclass;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tut.hibernate.modelclass.Employee;
import com.tut.hibernate.sessclass.EmployeeM1;

* Servlet implementation class EmServl
public class EmServl extends HttpServlet {
private static final long serialVersionUID = 1L;

* @see HttpServlet#HttpServlet()
public EmServl() {
// TODO Auto-generated constructor stub

* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub

Employee e = new Employee();

EmployeeM1 p = new EmployeeM1();
String message = "Your Data Inserted";
request.setAttribute("message", message);

RequestDispatcher dispatcher = request.getRequestDispatcher("/first.jsp");

* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub




package com.tut.hibernate.sessclass;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.tut.hibernate.buildclass.HibernateUtil;
import com.tut.hibernate.modelclass.Employee;

public class EmployeeM1 {

public void addEmp(Employee a) {

Transaction transaction = null;
Session session = HibernateUtil.getSessionFactory().openSession();

try {
transaction = session.beginTransaction();

}catch(RuntimeException e) {
if(transaction != null){




Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.