• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP error 405

 
shilpa nara
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have been trying to run this very simple servlet... but i get the foll error:
Apache Tomcat/4.0.3 - HTTP Status 405 - HTTP method GET is not supported by this URL
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).
------------
My code is as follows
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class try1 extends HttpServlet
{
public void doGet(HttpServletResponse res, HttpServletRequest req) throws ServletException, IOException
{
res.setContentType("Text/HTML");
PrintWriter out= res.getWriter();
out.println("<HTML>");
out.println("<Body>");
out.println("First Servlet");
out.println("</Body>");
out.println("</HTML>");
}
}

Can someone explain why this error occurs. Do i need to call this page from an HTML page
thanks
shilpa
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible your servlet is not even being loaded, much less called due to some sort of naming problem. You should add an init method and have that init method do a System.out or write to a log so you can tell if it is even being initialized. (oh - also you need to close out so it will be flushed.)
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic