Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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

 
Greenhorn
Posts: 3
  • 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!
 
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you put override annotation
 
Megan Gardner
Greenhorn
Posts: 3
  • 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
  • Likes 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..
 
Greenhorn
Posts: 25
Java
  • 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">
 
They weren't very bright, but they were very, very big. Ad contrast:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic