HTTP Status 405 - HTTP method GET is not supported by this URL
When I'm working with Java Servlet, I encountered "HTTP Status 405" error. But code seems to legit. The problem was, servlet doGet method calling super method.
package uk.co.andromedatech.onlineradio;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Test extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
super.doGet(req, resp);
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("Leann....");
}
}
package uk.co.andromedatech.onlineradio;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Test extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
// TODO Auto-generated method stub
super.doGet(req, resp);
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("Leann....");
}
}
After removal of red marked code selection, servlet compiled and started to work.
Comments
Post a Comment