首页 > 数据库 > mysql教程 > mysql-学渣妹纸·······servlet,jsp跳转问题

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

WBOY
发布: 2016-06-06 09:40:12
原创
994 人浏览过

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

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>



UserLogin page



管理员登陆界面



















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

管理员:
(不识别中文,请输入英文)


密 码:





注册新管理员



退出管理员界面







相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板