servlets - Getting HTTP Status 405 - HTTP method GET is not supported by this URL -



servlets - Getting HTTP Status 405 - HTTP method GET is not supported by this URL -

import java.io.ioexception; import java.io.printwriter; import javax.servlet.servlet; import javax.servlet.servletconfig; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; public class servletconfig1 extends httpservlet { @override public void dopost(httpservletrequest req,httpservletresponse res)throws servletexception ,ioexception{ printwriter pw = res.getwriter(); servletconfig cfg = getservletconfig(); string myname = cfg.getinitparameter("myname"); pw.print("my name is"+myname); system.out.println("hello"); } }

web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0"> <display-name>servletconfig</display-name> <servlet> <servlet-name> servletconfig1</servlet-name> <servlet-class>servletconfig1</servlet-class> <init-param> <param-name>myname</param-name> <param-value>saurabh</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>servletconfig1</servlet-name> <url-pattern>/index</url-pattern> </servlet-mapping> </web-app>

while running servletconfig illustration getting http method not supported though have used post method in application.what reason?

change public void dopost(httpservletrequest req,httpservletresponse res) public void doget(httpservletrequest req,httpservletresponse res).

http servlets

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -