Advertisement
yshhuu

servlet predict

Aug 18th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  2. try{
  3. HttpSession session=request.getSession();
  4.  
  5. RequestDispatcher rd=null;
  6.  
  7. Class.forName("oracle.jdbc.Driver.OracleDriver");
  8. Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","Admin");
  9. String itemid=null;
  10. itemid=request.getParameter("id");
  11. Statement st=con.createStatement();
  12. ResultSet rs=st.executeQuery("select quantity from item where id='"+id+"'");
  13. int value;
  14. while(rs.next())
  15. {
  16. value=rs.getInt("quantity");
  17. if(value<4)
  18. { session.setattribute("itemid",id);
  19. rd.getRequestDisspatcher("FormDisplay.jsp")
  20.  
  21. }
  22.  
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement