Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

/test/GreetingServlet doesn't work

 
Hui Zhao
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using NetBeans 6 to configue a servlet. The Tomcat server is bunded within NetBeans. So it is not necessary to set up classpath and copy folders etc as with Eclipse.
I followed the totorial, it does work. However if I modified it a little.
index.jsp is

web,xml is


If I go to http://localhost:8080/test/GreetingServlet
I got


Why?
Thanks
[ January 23, 2008: Message edited by: Ulf Dittmer ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"test" is your contextPath (web application name) so you shouldn't need to include it in your servlet-mapping.

Change it to:
<url-pattern>/GreetingServlet</url-pattern>
and see if that fixes it.

Once you get past this, you should see our article on creating context relative paths.
http://faq.javaranch.com/java/ResourceUrls

This is a much better way to go than hard coding the contextPath in your URLs.
 
Hui Zhao
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is still not working.
I modified it in many combinations.
In web.xml, or index.jsp and context.xml.


Thanks for your advice.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Hui Zhao:
It is still not working.
I modified it in many combinations.
In web.xml, or index.jsp and context.xml.
...


This doesn't give us a lot with which to work.

What is the full path to your index.jsp page on your hard drive, starting with the drive letter?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does your servlet-mapping entry look like now?

You should not have to modify context.xml for this to work.
 
Hui Zhao
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The full path of index.jsp is in
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben's first post explained why that doesn't work. Did you implement the fix he suggested?
 
Hui Zhao
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have changed it.


But when I deployed it. I got
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I recommend that people starting out learning servlets put their IDE aside until they are comfortable writing, compiling, and deploying at least a simple 'Hello, World' program in a spec compliant container like Tomcat.

I don't know how Netbeans is deploying your apps within Tomcat so I can't be of much help to you.
I'm going to move this thread to our IDEs forum where you stand a better chance of finding someone who knows what it does.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic