import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import org.hibernate.*; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; public class KoerteServlet extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { PrintWriter out=resp.getWriter(); try{ Configuration c=new Configuration().configure(); ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings( c.getProperties()).build(); SessionFactory sessionFactory=c.buildSessionFactory(serviceRegistry); Session s=sessionFactory.openSession(); Koer k=(Koer)s.get(Koer.class, 1); out.println(k.koeranimi); s.close(); ((StandardServiceRegistryImpl) serviceRegistry).destroy(); }catch(Exception ex){ ex.printStackTrace(out); } } } /* D:\jetty\webapps\baas\WEB-INF\classes>javac -cp \jetty\lib\servlet-api-3.1.jar;. HaldamiseServlet.java */