File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes HTTP error 405 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "HTTP error 405" Watch "HTTP error 405" New topic
Author

HTTP error 405

shilpa nara
Greenhorn

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.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

Joined: Mar 22, 2000
Posts: 12268
    
    1
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


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP error 405
 
Similar Threads
getting 500 error when trying to run a servlet
Getting problem with post method
HTTP Status 405 error plz help
Head First JSP Book Ch1 Example
Using getNamedDispatcher() to forward a request