• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

confusion err message "HTTP method GET is not supported by this URL"

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, so I'm trying to figure out all of this servlet stuff. Here is what I did:

First, using one of the WORKING examples from apache tomcat 6, I took this:



copied it and changed the class name to blabla, so now the line that said:



says this:



and yes, I did name the file blabla.java and i didn't get compiler err.

I compiled the program and moved the blabla.class file to the same folder that the HelloWorldExample.class file was located. I then added the following lines of code to the web.xml file located in the webapps/examples/WEB-INF folder:



When I go to the URL

http://localhost:8080/examples/servlets/servlet/HelloWorldExample

it works fine, but when I go to

http://localhost:8080/examples/servlets/servlet/blabla

I get the message:

HTTP method GET is not supported by this URL

And the description:

The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

I have read up, and it seems this is a common error which usually occurs because people don't override the super class doGet method provided by the HttpServlet class, but if you look at my code, I obviously do that.

So to recap, I copied WORKING HelloWorldExample servlet and renamed HelloWorldExample to blabla in the java file. I then compiled it and moved blabla.class to the same location as HelloWorldExample.class. I then added to web.xml to configure url mapping.

Was there something else that I missed? Is there something obvious that my frustration is blinding me from? Thanks in advance for the help.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first thing to do, in order to eliminate it as a possible source of error, is to move your class to a package other than the default.

Yeah, the other class appears to be working, but it's a poor practice and can lead to issues. Let's eliminate it a source of issues and move on if the problem persists. (As well as just getting into a good habit.)
 
David Westbrook
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't really fix this per say. I made a new dynamic web project on eclipse and used the defaults from there and ran it and it worked. I do think that I could have used package manager to fix it like Bear suggested (thnx) but right now I need to move on. If I have time to revisit this later I will, but for now I have a project deadline to meet, so I'm going to keep moving.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic