3 Replies Latest reply on Dec 3, 2008 11:04 AM by Peter Johnson

    "HTTP Status 405: HTTP method GET is not supported by this U

    Michael Rollins Newbie

      I've been looking all over the web, and I keep coming up with the same solution, which is that you need to override doGet. Seems simple, right?

      However, I am overriding doGet, and I've even taken the simple servlet down to an even simpler level, and I'm still getting a 405 error.

      Briefly, I have created a web service that will return a PNG image as a byte array to the client. I created a simple client that receives the byte array. That client is called by a servlet. The servlet is supposed to write the byte array out to the browser.

      Here's my servlet code:

      package org.casm.gadget.chart.client;
      import java.io.IOException;
      import javax.servlet.ServletException;
      import javax.servlet.ServletOutputStream;
      import javax.servlet.http.HttpServlet;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
       * Servlet implementation class ChartClient
      public class ChartClientServlet extends HttpServlet {
       private static final long serialVersionUID = 1L;
       * @see HttpServlet#HttpServlet()
       public ChartClientServlet() {
       // TODO Auto-generated constructor stub
       * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       super.doGet(request, response);
       ChartClient cc = new ChartClient();
       ServletOutputStream out = response.getOutputStream();
       PrintWriter out = response.getWriter();
       }catch(Exception e){
       * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       // TODO Auto-generated method stub
       super.doPost(request, response);
       doGet(request, response);

      Everything up to writing the byte array out works. The web service is returning, and the byte array is getting passed to the servlet, but alas, only 405.

      If you look in the doGet method, you can see where I tried another, simpler version where the servlet only prints "Hi". This also resulted in the 405 error.

      I'm using JBoss 4.2.3.GA (the JDK6 version).