0

I have a servlet that extends HttpServlet in an Apache tomcat environment.

It has a doPost override.

I am trying to access via an HttpURLConnection with setDoOutput = true.

The client gets a 405 however the work is still performed by the Tomcat server as evidenced by entries in the Tomcat log.

I did find a Limit POST in the httpd.conf file and removed it and restarted Apache.

<Location /servlets>
   <Limit POST>
     Order deny,allow
     Deny from all
     Allow from localhost
     Satisfy any
   </Limit>
</Location>

Same results.

If I change the client to GET I get a 405 as would be expected, no doGet.

The Apache logs are correctly reflecting whether the client request is a GET or POST depending on what flavor I send.

It sure seems like this should have been the issue but no luck

Anywhere else to look?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Craig
  • 1
  • How exactly is that HTTPD config relevant to the question? Is your Tomcat fronted by HTTPD with mod_jk? Are you implying that it works fine when your Tomcat is not fronted by HTTPD but instead connected directly? And if so, thus the problem is caused by HTTPD? In that case, this is not a programmer's problem, but just a serveradmin's problem. Your question should then be migrated to serverfault.com. – BalusC Jul 24 '13 at 17:59

2 Answers2

0

HttpURLConnection recieving a 405 but service is completed

As the error clearly says, you seems to be using an HTTP method which is not supported by your servlet. As you have mentioned that your servlet has only doPost overriden, so it can only handle POST request. And you seems to be using some other HTTP method while sending the request.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
  • 1
    *"HttpURLConnection with setDoOutput = true"* as the OP clearly says implies that POST is been used by the client. See also http://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests for an elaborate tutorial on how to use/understand `URLConnection`. – BalusC Jul 24 '13 at 17:57
0

Thanks for the response. We had a class A that extended HttpServlet. All of are other servlets B's extended A and they all implicitly executed A's super. I was attempting to get rid of A by having a B extend HttpServlet directly. What I didn't notice was that all the B's were explicity executing what used to be A's super.doPost(). When A was omitted the super.doPost() was that of HttpServlet which seemed to cause the problem. Once I removed the super.doPost() everything started working as expected.

Craig
  • 1