Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package JSPMultipleForms;
- import java.io.*;
- import java.sql.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- public class LoginAut extends HttpServlet{
- private ServletConfig config;
- public void init(ServletConfig config)
- throws ServletException{
- this.config=config;
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException,IOException{
- HttpSession session = request.getSession(true);
- PrintWriter out = response.getWriter();
- String connectionURL = "jdbc:mysql://mysql.cmi-hro.nl:3306/cmi0814619";
- Connection connection=null;
- ResultSet rs;
- String userName=new String("");
- String passwrd=new String("");
- response.setContentType("text/html");
- try {
- // Load the database driver
- Class.forName("com.mysql.jdbc.Driver");
- // Get a Connection to the database
- connection = DriverManager.getConnection(connectionURL, "cmi0814619", "0000000");
- //Add the data into the database
- String sql = "select achternaam,reserverings_nr from cmi0814619.klanten where reserverings_nr="+request.getParameter("pass")+"";
- Statement s = connection.createStatement();
- s.executeQuery (sql);
- rs = s.getResultSet();
- while (rs.next ()){
- userName=rs.getString("achternaam");
- passwrd=rs.getString("reserverings_nr");
- }
- rs.close ();
- s.close ();
- }catch(Exception e){
- System.out.println("Exception is ;"+e);
- }
- if(userName.equals(request.getParameter("user"))
- && passwrd.equals(request.getParameter("pass"))){
- session.setAttribute("userName", userName);
- session.setAttribute("passwrd", passwrd);
- String nextJSP = "enq_p1.jsp";
- response.sendRedirect(nextJSP);
- }else{
- String nextJSP = "fout_ingelogd.jsp";
- response.sendRedirect(nextJSP);
- }
- }
- }
Add Comment
Please, Sign In to add comment