java - Tomcat 8: HTTP Status 405 - HTTP method GET is not supported by this URL -
i have servlet
, jsp
page. jsp
page contains form end user fill out.
<html> <head> <title>please log in profile</title> </head> <body> <form action="${pagecontext.request.contextpath}/login_servlet" method="post"> email: <input type="text" size="5" name="email"/> password: <input type="text" size="5" name="password"/> <input type="submit" value="sign in" /> </form> </body> </html>
i use dopost()
method in servlet because form has post method. parameters in servlet can print out console.
@webservlet("/login_servlet") public class loginservlet extends httpservlet { @override public void dopost(httpservletrequest req, httpservletresponse resp) throws servletexception, ioexception { string email = req.getparameter("email"); string password = req.getparameter("password"); system.out.println("email: " + email); system.out.println("password: " + password); } }
when try visit url http://localhost:8080/studentportal/login_servlet
error; http status 405 - http method not supported url
description "the specified http method not allowed requested resource."
i'm close being blocked asking anymore questions. please before marked duplicate, want know have looked @ similar questions , have followed advice given no avail.
i have learn servlets because i'm been put on spring project work soon.
when visit url, using get
method. , in servlet have declared dopost
method. try use postman extension chrome use other http methods.
*try access directly jsp page: localhost:8080/studentportal/pathtoyourjsppage
*you can add doget
method in servlet , call redirect there jsp page: response.sendredirect(location) or request.getrequestdispatcher(location).forward(request,response)
Comments
Post a Comment