This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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!
 
Rancher
Posts: 2021
15
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">
 
Maybe he went home and went to bed. And took this tiny ad with him:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!