java - Servlet Not Getting Hit In Simple JSP Application -
this question has answer here:
here servlet class
package com.jsp.servlet; import java.io.ioexception; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; @webservlet("/studentregistration") public class userservlet extends httpservlet { private static final long serialversionuid = 1l; @override protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { try { string username; username =(string)request.getparameter("name"); // system.out.println(fnameoperator); string condition = "where 1=1"; condition = condition + "and student_id = " + username; system.out.println(condition); } catch (exception e) { e.printstacktrace(); } { } request.getrequestdispatcher("login.jsp").forward(request, response); } }
view page post data in servlet
<form action="studentregistration" method="get"> <table> <tr> <td>name:</td> <td><input type="text" name="name" /></td> </tr> <tr> <td>email:</td> <td><input type="text" name="email" /></td> </tr> <tr> <td>password:</td> <td><input type="password" name="password" /></td> </tr> <tr> <td>gender:</td> <td><input type="radio" name="gender" value="m" />male <input type="radio" name="gender" value="f" />female</td> </tr> <tr> <td>image:</td> <td><input type="file" name="image" /></td> </tr> <tr> <td>resume:</td> <td><input type="file" name="resume" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="register" value="register" /> <input type="button" name="reset" value="reset" /></td> </tr> </table> </form>
this servlet mapping
<servlet> <servlet-name>userservlte</servlet-name> <servlet-class>com.jsp.servlet.userservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>userservlte</servlet-name> <url-pattern>/studentregistration</url-pattern> </servlet-mapping>
when i'm running application, , posting data index page(view page) servlet i'm getting 404
page not found.
i'm very new java development, please help.
guess there's typo in web.xml
<servlet> <servlet-name>userservlte</servlet-name> <servlet-class>com.jsp.servlet.userservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>userservlte</servlet-name> <url-pattern>/studentregistration</url-pattern> </servlet-mapping>
your servlet class called userservlet
on web.xml refer userservlte
Comments
Post a Comment