2 gnehzgnem gnehzgnem 于 2014.10.28 09:45 提问

servlet里面进行if语句的判断,由一个jsp页面显示不同结果

将注册信息提交到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);

}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!