• 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

/test/GreetingServlet doesn't work

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The full path of index.jsp is in
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have changed it.


But when I deployed it. I got
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic