Java codepackage com.weibo.servlets;
import java.io.*;
import java.sql.*;
import com.weibo.*;
import com.weibo.biz.UserAccountBiz;
import com.weibo.biz.impl.UserAccountBizImpl;
import com.weibo.dao.UserAccountDao;
import com.weibo.dao.impl.UserAccountDaoImpl;
import javax.jms.Session;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class LoginPass extends HttpServlet {
public LoginPass() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
boolean pass = false;
String email = request.getParameter("email");
String password = request.getParameter("password");
// response.setContentType("text/html");
// PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
UserAccountBiz userBiz = new UserAccountBizImpl();
boolean t = userBiz.isPassUser(email, password);
if(t){
System.out.println("t true");
}
if(t==false){
System.out.println("t false");
}
if (t) {
pass = true;
session.setAttribute("pass", pass);
session.setAttribute("email", email);
session.setAttribute("pwd", password);
// response.sendRedirect("pLogin2.jsp");
// RequestDispatcher requestDispatcher = request
// .getRequestDispatcher("pLogin2.jsp");
// requestDispatcher.forward(request, response);
request.getRequestDispatcher("index.jsp")
.forward(request, response);
} else {
pass = false;
session.setAttribute("email", email);
request.getRequestDispatcher("Login.jsp")
.forward(request, response);
// response.sendRedirect("pLogin2.jsp");
}
// out
// .println(""-//W3C//DTD HTML 4.01 Transitional//EN\">");
// out.println("");
// out.println("
A Servlet");// out.println("
");// out.print(" This is ");
// out.print(this.getClass());
// out.println(", using the POST method");
// out.println(" ");
// out.println("");
// out.flush();
// out.close();
}
public void init() throws ServletException {
// Put your code here
}
}