The moose likes Servlets and the fly likes HTTP error 405 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP error 405" Watch "HTTP error 405" New topic

HTTP error 405

shilpa nara

Joined: Dec 03, 2002
Posts: 3
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.util.*;
public class try1 extends HttpServlet
public void doGet(HttpServletResponse res, HttpServletRequest req) throws ServletException, IOException
PrintWriter out= res.getWriter();
out.println("First Servlet");

Can someone explain why this error occurs. Do i need to call this page from an HTML page
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
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.)
I agree. Here's the link:
subject: HTTP error 405
It's not a secret anymore!