servlet里面进行if语句的判断,由一个jsp页面显示不同结果
2014-11-06 来自:嘿嘿 0 人回应

将注册信息提交到treatUser.java里面后要进行处理,其中包括姓名或密码为空,密码和确认密码不一致,注册成功。然后要在treatResult.jsp里面显示处理结果。要怎么做?
这是treatUser.java部分代码:
response.setContentType("text/html;charset=GBK");
ServletContext application = getServletContext();
String name=request.getParameter("name");
String passw=request.getParameter("passw");
String repassw=request.getParameter("repassw");
String sex=request.getParameter("sex");
String hobby=request.getParameter("hobby");
String intro=request.getParameter("introduction");
if((name!=null&&passw!=null)&&(passw.equals(repassw))){

        application.setAttribute("userName",name);
        application.setAttribute("userPassword",passw);
        application.setAttribute("userPassword1",repassw);
        application.setAttribute("sex",sex);
        application.setAttribute("hobby",hobby);
        application.setAttribute("introduction",intro);
    }
    String url = "/zhuceResult.jsp";
    ServletContext sc = getServletContext();//sc即application
    RequestDispatcher rd = sc.getRequestDispatcher(url);
    rd.forward(request, response);

}
还没有人回应!

您的回应

你还未登陆,不能回应!登陆