Mysql-question of jsp redirection

Source: Internet
Author: User
Hey, student management system. Compiled using jsp, servlet, eclipse, and mysql. It seems to be servlet, and there is a problem with jsp jump. please help me. Add qq896151657. The following is a part of the code UserLogin. javapackagecom. servlet; importcom. dao. *; importcom. db. *; importcom. vo. *; importjava. io. IOException; importjava. io. printWriter; importjavax .... mysql jump to servletjsp

Hey, student management system. Compiled using jsp, servlet, eclipse, and mysql. It seems to be a servlet, and a problem occurs during jsp jump.
Please help me. Add qq896151657. Below is some code

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 ();

    String UserName=request.getParameter("UserName");

String UserPassword = request. getParameter ("UserPassword ");
User u = null;
UserDao us = null;
If (UserName. equals ("") | UserPassword. equals ("")){
Session. setAttribute ("userloginstr", "complete ");
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", "No such administrator ");
Request. getRequestDispatcher ("/UserLoginfail. jsp"). forward (request, response );
} Else {
Session. setAttribute ("userloginstr", "incorrect password or administrator name ");
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



Administrator logon page
















Administrator: (Chinese characters are not recognized. please enter English letters)
Password:
Register a new administrator


Exit administrator interface




















Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.