File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes /test/GreetingServlet doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "/test/GreetingServlet doesn Watch "/test/GreetingServlet doesn New topic
Author

/test/GreetingServlet doesn't work

Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
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

Joined: Dec 11, 2004
Posts: 13410

"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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
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

Joined: Dec 11, 2004
Posts: 13410

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
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
What does your servlet-mapping entry look like now?

You should not have to modify context.xml for this to work.


Ping & DNS - my free Android networking tools app
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116

The full path of index.jsp is in
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42591
    
  65
Ben's first post explained why that doesn't work. Did you implement the fix he suggested?
Hui Zhao
Ranch Hand

Joined: Jul 09, 2007
Posts: 116
I have changed it.


But when I deployed it. I got
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: /test/GreetingServlet doesn't work