点提交后就出现空白页面!郁闷中~~如果不加如数据库验证SERVLET可以正常跳转!加了之后就出现空白~~package webapp;import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import webapp.DBconnection;
import java.sql.*;public class loginservlet extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=GBK";    //Initialize global variables
    public void init() throws ServletException {
    }    //Process the HTTP Get request
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        response.setCharacterEncoding("GBK");
        String name = request.getParameter("username");
        String pwd = request.getParameter("password");
        try
        {
            Connection conn = DBconnection.getConnection();
            Statement stm = conn.createStatement();
            ResultSet rs = stm.executeQuery("select * from yonghu where name='" +name + "' and password='" + pwd + "'");
         if(rs.next())
         {
           RequestDispatcher rd=request.getRequestDispatcher("/welcome.jsp");
            rd.forward(request,response);
           }
        else{
            RequestDispatcher rd=request.getRequestDispatcher("/login.jsp");
            rd.include(request,response);             }            }
        catch (Exception exception) {
            exception.printStackTrace();
        }    }
    //Process the HTTP Post request
    //Clean up resources
    public void destroy() {
    }
}

解决方案 »

  1.   

    为什么你一个用include?一个用forword呢?
    如果我输入:用户名 or true
    密码随便输入,你试试会有什么结果?前提是这个用户名是存在的.
      

  2.   


    看这两个页面是不是跟 WEB-INF 平级
    如果平级就是
    welcome.jsp
    login.jsp
    反之就要加路径
      

  3.   

    select * from yonghu where name='" +name + "' and password='" + pwd + "'"
    典型的SQL注入漏洞。
    用户名和密码都用'or''='就可以登陆