• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error 405 -Http method get not supported by this url

 
niharika arora
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am learning JSP and i have Apache tomcat 4.1 on my machine. i had been able to compile and run servlets successfuly. i get this error while practising DIRECTIVES.

code for JSP:

<%@ page extends="usingjsp.jspSuperclass" %>
<html>
<body>
i a asubclass extending the superclass
this is a msg form my superclass : <br>
<%= request.getAttribute("demo") %>
</body>
</html>

code for servlet:
package usingjsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

public abstract class jspSuperclass extends HttpServlet implements HttpJspPage
{
public final void init(ServletConfig config) throws ServletException
{
super.init(config);
jspInit();
}

public final void destroy()
{
super.destroy();
jspDestroy();
}

public final ServletConfig getServletConfig()
{
return super.getServletConfig();
}

/*public final void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException,java.io.IOException
{
super.service(request,response);
} */

public final void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException
{
super.service(req,res);
req.setAttribute("demo","Hi from the superclass");
_jspService(req,res);
}

public void jspInit()
{
}

public void jspDestroy()
{
}

public abstract void _jspService(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,java.io.IOException ;
}

the location of jsp is: apache group\tomcat 4.1\root\nfiles\pagdir.jsp
location for servlet is: apache group\tomcat 4.1\root\nfiles\jspSuperclass.java
the compiled file jspSuperclass.class is present in both the nfiles\usingjsp folder as well as root\webapps\web-inf\classes folder.
 
Mat Williams
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am not sure about apache tomcat 4.x, I guess it works the same. For me using version 5.0.28 I needed to do the following

Override the doGet method of HttpServlet - remmeber this method if not overridden will give you the error you got by default.
so here is the code I added to JspSuperclass


I then had to restart tomcat and presto it worked.

HTH

Mat
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic