public class PostServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>\n <body>\n"); out.println(" <h2>\n Hello World\n </h2>\n"); out.println(" </body>\n</html>\n"); out.flush(); out.close(); } } this is the program i tried. in run time it will saying some "type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL). Apache Tomcat/5.0.28"
this is the output i am getting . after i changed doPost() to doGet() i am getting the answer...can any one explain regarding this.
There isn't much to explain. If you execute a GET request (say, by typing the URL into the browser), then the servlet needs to override the doGet method in HttpServlet. The default method in HttpServlet produces this error message.
-----------------------------------<br />If at first you don't succeed, try again without cry. Everytime You will learn what not to do next time, untill you succeed.<br /> <br />SCJP 1.4 (78%)<br />SCWCD 5 (95%)<br />BICT - UCSC