List of usage examples for org.hibernate Criteria list
public List list() throws HibernateException;
From source file:searchagent_byname.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w . jav a2 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.//from ww w .ja va 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 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 w w . ja va 2 s .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:GetPropDetailServ.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w .j av 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 { 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.// w w w. j a v a 2s . 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 { /* 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(); } }
From source file:ViewAgentFeedback.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from www . j a va2 s. 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(); HttpSession hs = request.getSession(); try { Login ln = (Login) hs.getAttribute("user"); System.out.println("uid is -------" + ln); SessionFactory sf = util.NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Criteria cr1 = ss.createCriteria(AgentDetail.class); cr1.add(Restrictions.eq("uId", ln)); ArrayList<AgentDetail> adl = (ArrayList<AgentDetail>) cr1.list(); if (!adl.isEmpty()) { AgentDetail ad = adl.get(0); System.out.print("adl not empty and the aid is :" + ad.getAId()); Criteria cr = ss.createCriteria(AgentFeedback.class); cr.add(Restrictions.eq("aId", ad)); ArrayList<AgentFeedback> afL = (ArrayList<AgentFeedback>) cr.list(); if (!afL.isEmpty()) { // HttpSession hs1=request.getSession(); System.out.println("adl size:" + adl.size() + "afl size:" + afL.size()); System.out.println("inside the servlet else"); System.out.println("inside the servlet else11"); request.setAttribute("afL", afL); System.out.println("inside the servlet else222"); } } RequestDispatcher rd = request.getRequestDispatcher("myfeedback_sample.jsp"); System.out.println("forwarding"); rd.forward(request, response); } catch (HibernateException e) { out.println(e.getMessage()); } }
From source file:forgotpassword.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w w 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 { String mail = request.getParameter("mail"); SessionFactory sf = HibernateUtil.getSessionFactory(); Session s = sf.openSession(); Transaction tr = s.beginTransaction(); Criteria c = s.createCriteria(Patient.class); c.add(Restrictions.eq("emailId", mail)); ArrayList<Patient> al = (ArrayList<Patient>) c.list(); String name = ""; if (al.size() > 0) { Patient p = al.get(0); Login l = p.getUsedId(); name = l.getPassword(); //name=l.getPassword(); System.out.println("---------------------" + name); String subject = "Forgot Password - Cardiac:"; String content = "Your password" + name; String[] recipients = new String[] { mail }; //String[] bccRecipients = new String[]{"sunilkotadiya777@gmail.com"}; if (new MailUtil().sendMail(recipients, subject, content)) { RequestDispatcher rd = request.getRequestDispatcher("forgetpassword_refresh.jsp"); rd.forward(request, response); } } else { String msg = "plz enter the correct email"; request.setAttribute("msg", msg); RequestDispatcher rd = request.getRequestDispatcher("forgotpassword.jsp"); rd.forward(request, response); } tr.commit(); } catch (HibernateException he) { out.println(he.getMessage()); } }
From source file:jobServ.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww. j av 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 j = request.getParameter("job"); Session se = NewHibernateUtil.getSessionFactory().openSession(); Transaction tr = se.beginTransaction(); Criteria cr = se.createCriteria(Job.class); cr.add(Restrictions.eq("jname", j)); ArrayList<Job> al = (ArrayList<Job>) cr.list(); tr.commit(); request.setAttribute("al", al); RequestDispatcher rd = request.getRequestDispatcher("job_search.jsp"); rd.forward(request, response); } catch (Exception e) { out.println(e.getMessage()); } }
From source file:getlab.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w ww . ja v a 2 s. 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 = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); String code = ""; Criteria cr = ss.createCriteria(Lab.class); ArrayList<Lab> all = (ArrayList<Lab>) cr.list(); // request.setAttribute("dlist", all); Criteria cr1 = ss.createCriteria(Lab.class); cr1.add(Restrictions.eq("status", "ACTIVE")); if (request.getParameter("sort") != null) { String so = request.getParameter("sort"); if (so.equals("1")) { cr1.addOrder(Order.asc("labName")); } else if (so.equals("2")) { cr1.addOrder(Order.desc("labName")); } //.add( Restrictions.like("name", "F%") //.addOrder( Order.asc("name") ) //.addOrder( Order.desc("age") ) //.setMaxResults(50) // cr.add(Restrictions.eq("password", request.getParameter("password"))); } if (request.getParameter("search") != null) { String so = request.getParameter("search"); cr1.add(Restrictions.like("labName", so + "%")); } ArrayList<Lab> all1 = (ArrayList<Lab>) cr1.list(); if (all1.size() > 0) { for (int i = 0; i < all1.size(); i++) { Lab dd = all1.get(i); out.println("<li class=\"author-comments\" style=\"margin-top: 36px\">\n" + " <div class=\"media\">\n" + " <div class=\"media-left\"> \n" + " <img alt=\"img\" src=\"images/Lab-Icon-245x300.png\" class=\"media-object news-img\"> \n" + " </div>\n" + " <div class=\"media-body\">\n" + " <h4 class=\"author-name\">" + dd.getLabName() + "</h4>\n" + " <a target='_blank' href='http://" + dd.getWebsite() + "'> <span class=\"comments-date\">" + dd.getWebsite() + "</span> </a>\n" + " <p>" + dd.getAddressid().getCityId().getCityName() + "</p>\n" + " <p class=\"fa fa-check-circle\" style=\"color: green\">" + dd.getStatus() + "</p>\n" + " <div class=\"ui heart rating\" data-rating=\"1\" data-max-rating=\"3\"></div>\n" + " <a class=\"reply-btn\" href=\"take_test?labid=" + dd.getLId() + "\">Take Appointment</a>\n" + " </div>\n" + " </div>\n" + " </li>"); } } } catch (HibernateException he) { he.getMessage(); } finally { out.close(); } }
From source file:doc_view_patient_allreport.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 { SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); HttpSession hs = request.getSession(); if (hs.getAttribute("doctor") != null) { Doctor a = (Doctor) hs.getAttribute("doctor"); if (request.getParameter("pid") != null) { int pid = Integer.parseInt(request.getParameter("pid")); // Calculationmeteredata cal = (Calculationmeteredata) ss.get(Calculationmeteredata.class, pid); Criteria cr = ss.createCriteria(Calculationmeteredata.class); cr.add(Restrictions.eq("pId", new Patient(pid))); ArrayList<Calculationmeteredata> da = (ArrayList<Calculationmeteredata>) cr.list(); if (da.size() > 0) { request.setAttribute("da", da); } tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("doctor_view_system_report.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(); } }