List of usage examples for org.hibernate SessionFactory openSession
Session openSession() throws HibernateException;
From source file:Home.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response);// ww w .j a va 2 s . c om System.out.println("run"); //configureer connectie Configuration cfg = new Configuration(); cfg.configure("Hibernate.cfg.xml"); SessionFactory sf = cfg.buildSessionFactory(); Session s = sf.openSession(); Transaction tx = s.beginTransaction(); //maak een employee Scoutslid scouts = new Scoutslid(); scouts.setNaam(request.getParameter("Naam")); scouts.setScoutsnaam(request.getParameter("Scoutsnaam")); scouts.setEmailadres(request.getParameter("Emailadres")); //bereid voor om weg te schrijven naar db s.save(scouts); s.flush(); //schrijf weg tx.commit(); //sluit connectie s.close(); //haal de employees op //open een sessie s = sf.openSession(); //Haal alle scoutsleden op List scoutsleden = s.createCriteria(Scoutslid.class).list(); ArrayList<Scoutslid> aScout = new ArrayList(); for (Iterator it1 = scoutsleden.iterator(); it1.hasNext();) { Scoutslid Sc = (Scoutslid) it1.next(); aScout.add(Sc); } request.getSession().setAttribute("Scoutslid", aScout); //sluit de connectie s.close(); request.getRequestDispatcher("results.jsp").forward(request, response); }
From source file:patreg.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w .j a va 2s. c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { String path = "refresh_page.jsp"; SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); Login lo = new Login(); lo.setUsername(request.getParameter("user_id")); lo.setPassword(request.getParameter("password")); lo.setRole("patient"); ss.save(lo); Addressdetails ad = new Addressdetails(); ad.setLine1(request.getParameter("line1")); ad.setLine2(request.getParameter("line2")); ad.setCity(request.getParameter("city")); ad.setState(request.getParameter("state")); ad.setPincode(request.getParameter("pincode")); ss.save(ad); Patient pi = new Patient(); pi.setPFirstname(request.getParameter("p_firstname")); pi.setPLastname(request.getParameter("p_lastname")); pi.setGender(request.getParameter("gender")); pi.setBirthDate(request.getParameter("birth_date")); pi.setContactNum(request.getParameter("contact_num")); pi.setEmailId(request.getParameter("email_id")); pi.setAddressid(ad); pi.setUsedId(lo); ss.save(pi); tr.commit(); RequestDispatcher rd = request.getRequestDispatcher(path); rd.forward(request, response); out.println("Success"); } catch (HibernateException he) { out.println(he.getMessage()); } }
From source file:GetCityServ.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w . j a v a2s . co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { /* TODO output your page here. You may use following sample code. */ SessionFactory sf = HibernateUtil.getSessionFactory(); Session se = sf.openSession(); Transaction tr = se.beginTransaction(); String sid = request.getParameter("state"); State sm = new State(); sm.setSId(Integer.parseInt(sid)); Criteria cr = se.createCriteria(City.class); cr.add(Restrictions.eq("stateId", sm)); ArrayList<City> cmli = (ArrayList<City>) cr.list(); for (int i = 0; i < cmli.size(); i++) { City cm = cmli.get(i); String cname = cm.getCityName(); out.print("<option value =" + cm.getCityId() + " >" + cname + "</option>"); } tr.commit(); } catch (Exception e) { out.println(e.getMessage()); } }
From source file:OrderSaveServ.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try {//from ww w. j a v a2s. c o m SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); ProductTable pt = new ProductTable(); pt.setPid(Integer.parseInt(request.getParameter("pid"))); OrderDetails od = new OrderDetails(); od.setPid(pt); od.setUserid(1); double amount = (Integer.parseInt(request.getParameter("qty"))) * (Integer.parseInt(request.getParameter("prate"))); od.setAmount(amount); System.out.println("Rate------" + request.getParameter("prate")); od.setQty(Integer.parseInt(request.getParameter("qty"))); od.setTstatus("Pending"); ss.save(od); tr.commit(); String pname = request.getParameter("pname"); String prate = request.getParameter("prate"); HttpSession hs = request.getSession(); hs.setAttribute("OrderDetails", od); request.setAttribute("pname", pname); request.setAttribute("prate", prate); RequestDispatcher rd = request.getRequestDispatcher("PaymentPage.jsp"); rd.forward(request, response); } catch (HibernateException e) { out.println(e.getMessage()); } }
From source file:searchagent_byname.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w.j a v a 2 s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { /* String name=request.getParameter("name"); Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection ("jdbc:mysql://localhost:3306/the_asset_consultancy?zeroDateTimeBehavior=convertToNull","root",""); Statement stmt = con.createStatement(); String query[] ={"SELECT * FROM emp where id=1", "select name from emp where name like 'ravi_'", "select name from emp where name like 'ravi%'"}; for(String q : query){ ResultSet rs = stmt.executeQuery(q); System.out.println("Names for query "+q+" are"); while (rs.next()) { String name = rs.getString("name"); System.out.print(name+" "); } } */ String searchedname = request.getParameter("agentname"); SessionFactory sf = util.NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Criteria cr1 = ss.createCriteria(AgentDetail.class); cr1.add(Restrictions.like("aFname", "%" + searchedname + "%")); ArrayList<AgentDetail> ad = (ArrayList<AgentDetail>) cr1.list(); //for (AgentDetail currentagent : ad) { // out.println(currentagent.getAId() + " " + currentagent.getAFname() + currentagent.getALname()); //} if (ad.isEmpty()) { out.print("no such agent"); String msg = "Sorry, No results found."; request.setAttribute("error", msg); } else { request.setAttribute("agent_array", ad); } RequestDispatcher rd = request.getRequestDispatcher("getstate?id=4"); rd.forward(request, response); } catch (Exception e) { out.println(e.getMessage()); } }
From source file:reg_serv_agent.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w w w . j a v a 2 s.com * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { String fn = request.getParameter("fname"); String ln = request.getParameter("lname"); String un = request.getParameter("uname"); String e = request.getParameter("email"); String stateid = request.getParameter("state"); System.out.println("-------" + stateid); String cityid = request.getParameter("city"); System.out.println("-------" + cityid); String r = request.getParameter("role"); String p = request.getParameter("pwd"); String areaid = request.getParameter("area"); System.out.println("-------" + areaid); String no = request.getParameter("num"); String adrs1 = request.getParameter("addrss"); String adrs2 = request.getParameter("addrss2"); Login li = new Login(); li.setUName(un); li.setPwd(p); li.setURole("agent"); SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); ss.save(li); String state = ""; Criteria cr = ss.createCriteria(StateMaster.class); cr.add(Restrictions.eq("sId", Integer.parseInt(stateid))); ArrayList<StateMaster> ar = (ArrayList<StateMaster>) cr.list(); System.out.println("----------" + ar.size()); if (ar.isEmpty()) { } else { state = ar.get(0).getSName(); System.out.println("-------" + ar.get(0)); } String city = ""; Criteria cr2 = ss.createCriteria(CityMaster.class); cr2.add(Restrictions.eq("cityId", Integer.parseInt(cityid))); ArrayList<CityMaster> ar2 = (ArrayList<CityMaster>) cr2.list(); System.out.println("----------" + ar2.size()); if (ar2.isEmpty()) { } else { city = ar2.get(0).getCityName(); System.out.println("-------" + city); } String area = ""; Criteria cr3 = ss.createCriteria(AreaMaster.class); cr3.add(Restrictions.eq("areaId", Integer.parseInt(areaid))); ArrayList<AreaMaster> ar3 = (ArrayList<AreaMaster>) cr3.list(); System.out.println("----------" + ar3.size()); if (ar3.isEmpty()) { } else { area = ar3.get(0).getAreaName(); System.out.println("-------" + area); } AgentDetail ad = new AgentDetail(); ad.setUId(li); ad.setAFname(fn); ad.setALname(ln); ad.setAAddress1(adrs1); ad.setAAddress2(adrs2); ad.setARating(0); ad.setAEmail(e); ad.setAState(state); ad.setACity(city); ad.setAArea(area); ad.setAStatus("Pending"); ad.setANo(no); ss.save(ad); // out.println("Agent Registered"); tr.commit(); HttpSession session = request.getSession(); session.setAttribute("user", li); RequestDispatcher rd = request.getRequestDispatcher("login.jsp"); rd.include(request, response); } catch (Exception e) { out.print(e.getMessage()); } }
From source file:search_prop.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w ww . java 2s . co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); String[] bhkGroup = request.getParameterValues("bhkgroup"); String[] typeGroup = request.getParameterValues("typegroup"); System.out.println("the types are:" + typeGroup[0]); System.out.println("the bhks are:" + bhkGroup[0]); String stateid = request.getParameter("state"); String cityid = request.getParameter("city"); String areaid = request.getParameter("area"); // String minp = request.getParameter("minprice"); // String maxp = request.getParameter("maxprice"); // String minsq = request.getParameter("minsqfeet"); // String maxsq = request.getParameter("maxsqfeet"); // //Edited int minp = Integer.parseInt(request.getParameter("minprice")); int maxp = Integer.parseInt(request.getParameter("maxprice")); int minsq = Integer.parseInt(request.getParameter("minsqfeet")); int maxsq = Integer.parseInt(request.getParameter("maxsqfeet")); String state = ""; Criteria cr1 = ss.createCriteria(StateMaster.class); cr1.add(Restrictions.eq("sId", Integer.parseInt(stateid))); ArrayList<StateMaster> ar = (ArrayList<StateMaster>) cr1.list(); System.out.println("----------" + ar.size()); if (ar.isEmpty()) { } else { state = ar.get(0).getSName(); System.out.println("-------" + state); } String city = ""; Criteria cr2 = ss.createCriteria(CityMaster.class); cr2.add(Restrictions.eq("cityId", Integer.parseInt(cityid))); ArrayList<CityMaster> ar2 = (ArrayList<CityMaster>) cr2.list(); System.out.println("----------" + ar2.size()); if (ar2.isEmpty()) { } else { city = ar2.get(0).getCityName(); System.out.println("-------" + city); } String area = ""; Criteria cr3 = ss.createCriteria(AreaMaster.class); cr3.add(Restrictions.eq("areaId", Integer.parseInt(areaid))); ArrayList<AreaMaster> ar3 = (ArrayList<AreaMaster>) cr3.list(); System.out.println("----------" + ar3.size()); if (ar3.isEmpty()) { } else { area = ar3.get(0).getAreaName(); System.out.println("-------" + area); } System.out.println(minp + " " + maxp + " " + minsq + " " + maxsq); Criteria cr = ss.createCriteria(PropDetail.class); cr.add(Restrictions.in("pBhk", bhkGroup)); cr.add(Restrictions.in("pType", typeGroup)); cr.add(Restrictions.eq("pState", state)); cr.add(Restrictions.eq("pCity", city)); cr.add(Restrictions.eq("pArea", area)); cr.add(Restrictions.between("pPrice", minp, maxp)); cr.add(Restrictions.between("pFloor", minsq, maxsq)); ArrayList<PropDetail> pd = (ArrayList<PropDetail>) cr.list(); /* for(PropDetail p: pd) { out.print(p.getPId()+" type:"+p.getPType()+" bhk:"+p.getPBhk()); out.println(" "); } */ if (pd.isEmpty()) { out.print("no such property"); String msg = "Sorry, No results found."; request.setAttribute("error", msg); } else { request.setAttribute("proplist", pd); } RequestDispatcher rd = request.getRequestDispatcher("getstate?id=9"); rd.forward(request, response); } catch (HibernateException e) { out.println("There was some error with the taken action."); System.out.print(e.getMessage()); } }
From source file:addGeologist.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// www .ja va 2s.c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); String path = ""; try { /* TODO output your page here. You may use following sample code. */ String username = request.getParameter("username"); String password = request.getParameter("password"); String user_first_name = request.getParameter("user_first_name"); String user_last_name = request.getParameter("user_last_name"); String user_contact_number = request.getParameter("user_contact_number"); SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); LoginInfo loginInfo = new LoginInfo(); loginInfo.setUsername(username); loginInfo.setPassword(password); loginInfo.setRole("G"); ss.save(loginInfo); UserInfo userInfo = new UserInfo(); userInfo.setUserId(loginInfo); userInfo.setUserFirstName(user_first_name); userInfo.setUserLastName(user_last_name); userInfo.setUserContactNumber(user_contact_number); ss.save(userInfo); HttpSession hs = request.getSession(); tr.commit(); path = "SuccessGeo.jsp"; // spath = uri.replace("Mineriafinal/addMiningEngineer", "/Geologist/SuccessGeo.jsp"); RequestDispatcher rd = request.getRequestDispatcher(path); rd.forward(request, response); } catch (Exception e) { path = "FailureGeo.jsp"; RequestDispatcher rd = request.getRequestDispatcher(path); rd.forward(request, response); } }
From source file:GetPropDetailServ.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww . j a v a2s . co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = util.NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); int pid = Integer.parseInt(request.getParameter("pid")); ArrayList<AssetRecords> a = new ArrayList<>(); String s = "SELECT sum(Price),Year FROM the_asset_consultancy.AssetRecords where Assetid=" + pid + " group by Price,Year ;"; SQLQuery query = ss.createSQLQuery(s); List<Object[]> lt = query.list(); for (Object[] op : lt) { AssetRecords ar = new AssetRecords(); ar.setPrice(op[0].toString()); ar.setYear(op[1].toString()); a.add(ar); out.println(a); } System.out.println("Size of array:" + a.size()); request.setAttribute("al", a); Collections.sort(a, new Comparator<AssetRecords>() { @Override public int compare(AssetRecords o1, AssetRecords o2) { return o1.getYear().compareTo(o2.getYear()); } }); Criteria cr = ss.createCriteria(PropDetail.class); cr.add(Restrictions.eq("pId", pid)); PropDetail pd = (PropDetail) cr.uniqueResult(); System.out.println("property found:" + pd.getPId()); Criteria cr1 = ss.createCriteria(PropFeedback.class); cr1.add(Restrictions.eq("pId", pd)); ArrayList<PropFeedback> pfl = (ArrayList<PropFeedback>) cr1.list(); request.setAttribute("pd", pd); if (!pfl.isEmpty()) { request.setAttribute("pfl", pfl); } else { System.out.println("No property feedback available"); } //for the random agent display Criteria cr2 = ss.createCriteria(AgentDetail.class); ArrayList<AgentDetail> adl = (ArrayList<AgentDetail>) cr2.list(); if (!adl.isEmpty()) { request.setAttribute("adl", adl); } else { System.out.println("random agent list empty"); } RequestDispatcher rd = request.getRequestDispatcher("single.jsp"); rd.forward(request, response); } catch (HibernateException e) { out.print(e.getMessage()); } }
From source file:systemgen_report_doc.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . ja v a 2s. co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { /* TODO output your page here. You may use following sample code. */ SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); HttpSession hs = request.getSession(); if (hs.getAttribute("doctor") != null) { Patient p1 = (Patient) hs.getAttribute("patient"); if (request.getParameter("calcid") != null) { int calcid = Integer.parseInt(request.getParameter("calcid")); Calculationmeteredata cm1 = (Calculationmeteredata) ss.get(Calculationmeteredata.class, calcid); String color = "red"; if (cm1.getCalculationmeteredataId() != null) { String gender = "MALE"; Criteria optcr = ss.createCriteria(PatientfactorAnswer.class); optcr.add(Restrictions.eq("calculationmeteredataId", cm1)); ArrayList<PatientfactorAnswer> anslist = (ArrayList<PatientfactorAnswer>) optcr.list(); if (anslist.size() > 0) { FactorOption agefac = new FactorOption(); for (PatientfactorAnswer opp : anslist) { if (opp.getFactorId().equals(new FactorDetails(1))) { if (opp.getFactorOptionId().getFoptionId().equals(16)) { gender = "FEMALE"; } System.out.println("Gender is :" + gender + opp.getFactorOptionId()); } if (opp.getFactorId().equals(new FactorDetails(2))) { agefac = opp.getFactorOptionId(); System.out.println("Age is :" + agefac.getFactorOption()); } } if (gender.equals("MALE")) { // Set Chart Data String[] chartdata = new String[4]; String[] rchartdata = new String[4]; Criteria cr01 = ss.createCriteria(AbsulateRiskMale.class); cr01.add(Restrictions.eq("foptionid", agefac)); cr01.setProjection(Projections.max("green")); if (cr01.uniqueResult() != null) { chartdata[0] = cr01.uniqueResult().toString(); int cdata = Integer.parseInt(chartdata[0]); if (cdata >= cm1.getMetervalue()) { color = "green"; } } Criteria cr02 = ss.createCriteria(AbsulateRiskMale.class); cr02.add(Restrictions.eq("foptionid", agefac)); cr02.setProjection(Projections.max("violet")); if (cr02.uniqueResult() != null) { chartdata[1] = cr02.uniqueResult().toString(); int cdata = Integer.parseInt(chartdata[1]); if (cdata >= cm1.getMetervalue()) { color = "violet"; } } System.out.println(chartdata[1]); System.out.println(color); Criteria cr03 = ss.createCriteria(AbsulateRiskMale.class); cr03.add(Restrictions.eq("foptionid", agefac)); cr03.setProjection(Projections.max("yellow")); if (cr03.uniqueResult() != null) { chartdata[2] = cr03.uniqueResult().toString(); int cdata = Integer.parseInt(chartdata[2]); if (cdata >= cm1.getMetervalue()) { color = "yellow"; } } chartdata[3] = "54"; // RchartData create Criteria cr010 = ss.createCriteria(AbsulateRiskMale.class); cr010.add(Restrictions.eq("foptionid", agefac)); cr010.setProjection(Projections.max("rGreen")); if (cr010.uniqueResult() != null) { rchartdata[0] = cr010.uniqueResult().toString(); } Criteria cr020 = ss.createCriteria(AbsulateRiskMale.class); cr020.add(Restrictions.eq("foptionid", agefac)); cr020.setProjection(Projections.max("rViolet")); if (cr020.uniqueResult() != null) { rchartdata[1] = cr020.uniqueResult().toString(); } System.out.println(chartdata[1]); System.out.println(color); Criteria cr030 = ss.createCriteria(AbsulateRiskMale.class); cr030.add(Restrictions.eq("foptionid", agefac)); cr030.setProjection(Projections.max("rYellow")); if (cr030.uniqueResult() != null) { rchartdata[2] = cr030.uniqueResult().toString(); } rchartdata[3] = "30"; request.setAttribute("rchartdata", rchartdata); request.setAttribute("chartdata", chartdata); } else if (gender.equals("FEMALE")) { // Set Chart Data String[] chartdata = new String[4]; String[] rchartdata = new String[4]; Criteria cr01 = ss.createCriteria(AbsoluteRiskFemale.class); cr01.add(Restrictions.eq("foptionid", agefac)); cr01.setProjection(Projections.max("green")); if (cr01.uniqueResult() != null) { chartdata[0] = cr01.uniqueResult().toString(); int cdata = Integer.parseInt(chartdata[0]); if (cdata >= cm1.getMetervalue()) { color = "green"; } } Criteria cr02 = ss.createCriteria(AbsoluteRiskFemale.class); cr02.add(Restrictions.eq("foptionid", agefac)); cr02.setProjection(Projections.max("violet")); if (cr02.uniqueResult() != null) { chartdata[1] = cr02.uniqueResult().toString(); int cdata = Integer.parseInt(chartdata[1]); if (cdata >= cm1.getMetervalue()) { color = "violet"; } } Criteria cr03 = ss.createCriteria(AbsoluteRiskFemale.class); cr03.add(Restrictions.eq("foptionid", agefac)); cr03.setProjection(Projections.max("yellow")); if (cr03.uniqueResult() != null) { chartdata[2] = cr03.uniqueResult().toString(); int cdata = Integer.parseInt(chartdata[2]); if (cdata >= cm1.getMetervalue()) { color = "yellow"; } } chartdata[3] = "30"; // RchartData create Criteria cr010 = ss.createCriteria(AbsoluteRiskFemale.class); cr010.add(Restrictions.eq("foptionid", agefac)); cr010.setProjection(Projections.max("rGreen")); if (cr010.uniqueResult() != null) { rchartdata[0] = cr010.uniqueResult().toString(); } Criteria cr020 = ss.createCriteria(AbsoluteRiskFemale.class); cr020.add(Restrictions.eq("foptionid", agefac)); cr020.setProjection(Projections.max("rViolet")); if (cr020.uniqueResult() != null) { rchartdata[1] = cr020.uniqueResult().toString(); } System.out.println(chartdata[1]); System.out.println(color); Criteria cr030 = ss.createCriteria(AbsoluteRiskFemale.class); cr030.add(Restrictions.eq("foptionid", agefac)); cr030.setProjection(Projections.max("rYellow")); if (cr030.uniqueResult() != null) { rchartdata[2] = cr030.uniqueResult().toString(); } rchartdata[3] = "20"; request.setAttribute("rchartdata", rchartdata); request.setAttribute("chartdata", chartdata); } Criteria testcr = ss.createCriteria(TestRecommend.class); testcr.add(Restrictions.eq("color", color)); ArrayList<TestRecommend> tlist = (ArrayList<TestRecommend>) testcr.list(); if (tlist.size() > 0) { request.setAttribute("testlist", tlist); } request.setAttribute("calcdata", cm1); request.setAttribute("anslist", anslist); } } tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("doctor_view_systemreport_full.jsp"); rd.forward(request, response); } } else { tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("login.jsp"); rd.forward(request, response); } } catch (HibernateException he) { out.println(he.getMessage()); } finally { out.close(); } }