Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Megan Gardner
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you put override annotation
 
Megan Gardner
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic