没有从我的jsp

时间:2016-06-27 06:23:48

标签: servlets

当我点击提交按钮时......没有调用servlet .. 它显示了相同的index.jsp页面...... 哪里是我无法找到的错误..请帮帮我

//这是我的jsp                                                                                                  名称                                                                                                                                                                                                        性别                                                                               男                                                                               女                                                                                                                         电子邮件                                                                                                                                                                                                        密码                                                                                                                                                                                                        联系                                                                                                                                                                                                                                                                                                                                                                    

//here is my web.xml
<servlet>
        <servlet-name>Register</servlet-name>
        <servlet-class>servlet.Register</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Register</servlet-name>
        <url-pattern>/Register</url-pattern>
    </servlet-mapping>

//here my Register.java

@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
         PrintWriter writer = response.getWriter();
    writer.print("something");

        try {
            processRequest(request, response);
            UserModal user=new UserModal();
            user.setName(request.getParameter("uname"));
            user.setGender(request.getParameter("usex"));
            user.setEmail(request.getParameter("uemail"));
            user.setPassword(request.getParameter("upass"));
            user.setContact(request.getParameter("ucontact"));
            boolean result=new UserService().registerUser(user);
            if(result){
                response.sendRedirect("welcome.jsp");
            }
            else{
                response.sendRedirect("index.jasp?msg=fail");
            }
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Register.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

1 个答案:

答案 0 :(得分:-1)

请参考以下链接中的一些jsp-servlet示例。您可以更多地了解servlet doPost()调用。