首頁 > 資料庫 > mysql教程 > mysql-学渣妹纸·······servlet,jsp跳转问题

mysql-学渣妹纸·······servlet,jsp跳转问题

WBOY
發布: 2016-06-06 09:40:12
原創
997 人瀏覽過

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



UserLogin page



管理员登陆界面



















管理员: (不识别中文,请输入英文)
密 码:
注册新管理员


退出管理员界面




















相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板