mysql跳转servletjsp
呜呜,学生管理系统。用jsp,servlet,eclipse,mysql编成。貌似是servlet,jsp跳转出现了问题
.求大神帮帮忙。加qq896151657。下面是部分代码
UserLogin.java
package com.servlet;
import com.dao.*;
import com.db.*;
import com.vo.*;
import java.io.IOException;
import java.io.PrintWriter;
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 UserLogin extends HttpServlet {
public UserLogin() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
response.setCharacterEncoding("gbk");
request.setCharacterEncoding("gbk");
HttpSession session=request.getSession();
//PrintWriter out=response.getWriter();
<code> String UserName=request.getParameter("UserName");</code>
String UserPassword=request.getParameter("UserPassword");
User u=null;
UserDao us=null;
if(UserName.equals("")||UserPassword.equals("")){
session.setAttribute("userloginstr","请填写完整");
request.getRequestDispatcher("/UserLoginfail.jsp").forward(request,response);
}else{
u=new User();
us=new UserDao();
u.setUserName(UserName);
u.setUserPassword(UserPassword);
User u1=us.selectInformation(u);
//System.out.println(userName);
//System.out.println(u1.getUserName());
if(UserName.equals(u1.getUserName())&&UserPassword.equals(u1.getUserPassword()))
{
session.setAttribute("userloginname",UserName);
request.getRequestDispatcher("/User.jsp").forward(request,response);
}else{
if(!UserName.equals(u1.getUserName())){
session.setAttribute("userloginstr","没有此管理员");
request.getRequestDispatcher("/UserLoginfail.jsp").forward(request,response);
}else{
session.setAttribute("userloginstr","密码或管理员名不正确");
request.getRequestDispatcher("/UserLoginfail.jsp").forward(request,response);
}
}
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
public void init() throws ServletException {
}
}
UserLogin.jsp
管理员: | (不识别中文,请输入英文) | |
密 码: | ||
注册新管理员 |