This content has been marked as final.
Show 3 replies
-
1. Re: HTTP Status 405 - HTTP method GET is not supported by th
prakah Apr 4, 2007 6:49 AM (in response to aurir_)Hello,
405 status code will be return when you try to access an Http method(get/post/etc...) which is not available.
I think, you are having doGet method and you are asking for doPost. If that is the case, then by adding following code in the servlet will solve the problem.public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { doGet(req, res); }
-
2. Re: HTTP Status 405 - HTTP method GET is not supported by th
aurir_ Apr 4, 2007 4:56 PM (in response to aurir_)Keep in mind that when I return PLAIN TEXT:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ PrintWriter out = response.getWriter(); out.println("Hellow World"); }
There is no problem. I get this error only when I return HMTL:public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ super.doGet(request, response); //Tell the browser that you?re sending it HTML response.setContentType("text/html"); PrintWriter out = response.getWriter(); String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "+ "Transitional//EN\">\n"; out.println(docType + "<HTML>\n<HEAD>\n<TITLE>HELLO</TITLE>\n</BODY>\n</HTML>"); }
Could that be some server settings??? I'm running JBoss 4.0 -
3. Re: HTTP Status 405 - HTTP method GET is not supported by th
aurir_ Apr 4, 2007 5:42 PM (in response to aurir_)I have solved the problem. There was a couple errors:
1) When creating HTTPServlet in Eclipse I checked "include doGet()" which automatically included statement tosuper.get(req, res);
2) Another error that I had was very trivial. My HTML syntax was not valid.
http://validator.w3.org/ is a great webpage to validate HTML syntax.