aspose file tools*
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
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: 12769
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP error 405