A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Servlets
Author
HTTP method GET is not supported by this URL
arturo cruz
Greenhorn
Joined: Nov 16, 2011
Posts: 2
posted
Nov 16, 2011 21:24:23
0
I am trying to run a
servlet
using
tomcat
6 but cannot get past the HTTP method GET is not supported by this URL message. I have pasted below the servlet code, the web.xml and the directory structure.
Any help is appreciated.
******* the URL :
http://localhost:8080/listenerTest/ListenTest.do
********** the directory structure ****************
webapps
listenerTest
WEB-INF
classes
com
example
** the servlet goes here****
***********the servlet ******************
package com.example; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class listenerTester extends HttpServlet { public void goGet(HttpServletRequest req, HttpServletResponse res ) throws IOException, ServletException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.println("test context attributes set by the listener<br>"); Dog dog = (Dog) getServletContext().getAttribute("dog"); out.println("the dogs breed is : " + dog.getBreed()); } }
************** Web.xml ************************
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
"
version="2.4">
<description>
JSP
2.0 Examples.
</description>
<display-name>JSP 2.0 Examples</display-name>
<servlet>
<servlet-name>listenerTester</servlet-name>
<servlet-class>com.example.listenerTester</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>listenerTester</servlet-name>
<url-pattern>/ListenTest.do</url-pattern>
</servlet-mapping>
<context-param>
<param-name>breed</param-name>
<param-value>Great Dane</param-value>
</context-param>
<listener>
<listener-class>
com.example.myServletContextListener
</listener-class>
</listener>
</web-app>
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
13
I like...
posted
Nov 16, 2011 21:27:54
2
Check your spelling.
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
sagar kumar nerella
Greenhorn
Joined: Jul 09, 2011
Posts: 18
I like...
posted
Nov 17, 2011 12:10:24
0
hi
from examining your code posted at the very first glance it is clear that the method should be named doGet() not goGet() .
try this change if it doesn't works then try with the using the post method.
sagar kumar nerella,
java certified professional
arturo cruz
Greenhorn
Joined: Nov 16, 2011
Posts: 2
posted
Nov 17, 2011 15:00:03
0
That was the problem. doGet was mispelled as goGet. Amazing how I looked at the mehod name and didn't catch it.
Thank you Sagar and Bear.
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
Nov 17, 2011 15:08:46
1
An
excellent
example of why you need to get into the habit of using the @Override annotation.
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: HTTP method GET is not supported by this URL
Similar Threads
HFSJ page 171-177 problem
ContextListener
HFSJ Listener - Chapter 5 - /listenerTest/ 404 error
Error LlistenerStart
My Browser Ask Me For A Program To Open A Servlet
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter