简体   繁体   中英

Error while running Servlet?

I have the servlet name ExampleServlet.java which have only init method with HttpServletRequest and HttpServletResponse parameters. I will forward the request to another servlet named ForwardedServlet.java which will display some text on the web page. But when i am trying to execute the ExampleServlet http://localhost:8080/Sample/ExampleServlet the following error occurs.


The request sent by the client was syntactically incorrect (HTTP method GET is not supported by this URL).

Please give the solution and why it this error occured... Thanks in advance

You haven't implemented the 'doGet' method, so it's falling back to the default implementation, which is a 503 server error (or some variant).

The init is only called once, when the servlet is instantiated - it's not called once per request, which you'll need to do.

Also, make sure the capitalisation and arguments are correct; if you use something else, it won't be the right method that the Servlet API calls.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM