aspose file tools*
The moose likes Servlets and the fly likes 405 error for GET method and I have a doGet() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "405 error for GET method and I have a doGet()" Watch "405 error for GET method and I have a doGet()" New topic
Author

405 error for GET method and I have a doGet()

Megan Gardner
Greenhorn

Joined: May 23, 2013
Posts: 3
So I keep getting a 405 error about my GET method. I've double checked and I'm not doing the usual GET/POST mix-up. I've been working on this for two days and I just can't figure it out.
Also, my servlet can't be found unless I put a @Path on it...is that normal? Most of the examples I've seen don't do that but mine won't work any other way.

servlet:


index.jsp:


web.xml


Any help would be gladly appreciated! Thank you!
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

What happens if you put override annotation


Swastik
Megan Gardner
Greenhorn

Joined: May 23, 2013
Posts: 3
Unfortunately, I still get the error. I also get the error when I change all my get requests to posts and move the code.
Megan Gardner
Greenhorn

Joined: May 23, 2013
Posts: 3
This is embarrassing, I just fixed it. Obviously this happens.

In case this thread ever gets stumbled upon here was the solution:

1. In the servlet, replaced @Path with @WebServlet annotation
2. Changed the ajax call url to remove one of the uploadServ's
3. Watch magic occur.

I tried this two fixes, but apparently not at the same time. Whoops..
Rohit W. Tawde
Greenhorn

Joined: Mar 12, 2013
Posts: 25

Hi,

I did not understand this mapping,

<servlet-name>uploadServlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>

<servlet-mapping>
<servlet-name>uploadServlet</servlet-name>
<url-pattern>/uploadServ/*</url-pattern>
</servlet-mapping>

Your servlet name is uploadServlet and its in the package servlets.

Also if you use @WebServlet annotation, then its not necessary to map the servlet in the web.xml file.

web.xml contains a metadata-complete attribute in the web-app element.
If set to true all of these will be ignored and web.xml is the only metadata considered.

eg.
<web-app metadata-complete="true" ........version="3.0">

Rohit Tawde (SCJP5)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 405 error for GET method and I have a doGet()