Hello
Users
I have written a web based hibernate application
it includes following
a html page(
a baen(Event)
a servlet(EventManagerServlet)
servler.xml
web.xml

my error is
Unreported Naming Exception: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context

EventManagerServlet.java
package events;

import util.HibernateUtil;
import org.hibernate.*;
import org.hibernate.Hibernate;
import org.hibernate.criterion.Expression;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.*;
import java.util.*;
import java.text.SimpleDateFormat;
import javax.servlet.*;
import javax.naming.*;
import javax.sql.*;


public class EventManagerServlet extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{ doPost(req, res);}

public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();

String name = req.getParameter("username");
String password = req.getParameter("password");
String status= req.getParameter("status");

out.println("Your Name is: "+name);
out.println("Your paassword is:"+password);
out.println("Your Status is: "+status);

try
{
InitialContext initCtx = new InitialContext();
SessionFactory factory = (SessionFactory)initCtx.lookup("java:comp/env/jdbc/MyHibernate");
Session session = factory.openSession();
Transaction tx = null;
tx = session.beginTransaction();
Event eve = new Event();
eve.setUsername(name);
eve.setPassword(password);
eve.setStatus(status);
session.save(eve);
tx.commit();
session.flush();
session.close();
}
catch(Exception e1)
{System.out.println(""+e1);}
}
}

server.xml(tomcat/conf/server.xml)
<Context path="/MyHibernate" docBase="MyHibernate">
<Resource name="jdbc/MyHibernate" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/MyHibernate">
<parameter>
<name>factory</name>
<value>org.apache.tomcat.dbcp.BasicDataSource </value>
</parameter>

<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/MyHibernate</value>
</parameter>
<parameter>
<name>driverClassName</name><value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value>root</value>
</parameter>

<!-- DBCP connection pooling options -->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
</ResourceParams>
</Context>



web.xml(MyHibernate/Web-inf/web.xml)



<servlet>
<servlet-name>EventManagerServlet</servlet-name>
<servlet-class>events.EventManagerServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>



<servlet-mapping>
<servlet-name>EventManagerServlet </servlet-name>
<url-pattern>/servlet/EventManagerServlet</url-pattern>
</servlet-mapping>