Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.text.*;
- import java.util.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.sql.*;
- import BookStoreBeans.*;
- public class RegisterTry extends HttpServlet
- {
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws IOException, ServletException
- {
- PrintWriter out = res.getWriter();
- //delcare two objects to represent the log in user
- String FN = null;
- String LN = null;
- String EM = null;
- String PD = null;
- String ST = null;
- String CI = null;
- String STA = null;
- String ZC = null;
- String PH = null;
- String PWDH = null;
- //get the current session
- HttpSession session = req.getSession();
- FN = req.getParameter("firstName");
- LN = req.getParameter("lastName");
- EM = req.getParameter("email");
- PD = req.getParameter("password1");
- ST = req.getParameter("streetAddress1");
- CI = req.getParameter("city");
- STA = req.getParameter("state");
- ZC = req.getParameter("zip");
- PH = req.getParameter("phone");
- PWDH = req.getParameter("passwordHint");
- //Invalidate an old session if it exists
- //session.invalidate();
- //get a fresh session
- //session = request.getSession();
- Customer customer = new Customer();
- customer.setfname(FN);
- customer.setlname(LN);
- customer.setemail(EM);
- customer.setpassword(PD);
- customer.setuserid(1);
- customer.setstreet(ST);
- customer.setcity(CI);
- customer.setstate(STA);
- customer.setzipcode(ZC);
- customer.setphone(PH);
- customer.setpasswordhint(PWDH);
- session.setAttribute("customer", customer);
- String insertSql = "INSERT INTO customer (fname, lname, street, city, state, zipcode, phone, email, passwd, passwordhint) "
- + "VALUES ('" + FN + "', '"
- + LN + "', '" + ST + "', '" + CI + "', '" + STA
- + "', '" + ZC + "', '" + PH + "', '" + EM + "', '"
- + PD + "', '" + PWDH + "');";
- String sqlSearch = "Select * from customer where customer.email = '" + EM + "';";
- String URL = "jdbc:postgresql:Chappel";
- try
- {
- Class.forName("org.postgresql.Driver");
- Connection con = DriverManager.getConnection(URL, "postgres", "user");
- Statement stmt = con.createStatement();
- stmt.executeQuery(insertSql);
- }
- catch(Exception sqle)
- {
- res.sendRedirect("/Chappel/jsp/thankyou.jsp");
- }
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement