• 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

Problems setting the CLASSPATH for my servlets

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Afternoon;

I am a newbie trying to figure out how to simply get my first servlet to run. The servlet is name "HelloServlet."

The first initial test that I am running is a "Servlet That Does Not Use Packages." When I compile the file for the command prompt and use the URL localhost:1979/servlet/HelloServlet, I get an error message of stating that the requested resource (/servlet/HelloServlet) is not available.

I have checked my CLASSPATH, but I am not sure it setup correctly. All of my HTML and JSP files are working with my server except for the one servlet. I have been working on this since 7:00 a.m. this morning and now is 1:00 p.m. I am exhausted and hoping that someone has an answer as to what I am doing wrong in setting up my environment.

In addition, I keeping thinking that my web.xml file in the C:\tomcat\webapps\ROOT\WEB-INF needs to be modified. I have already followed the installation instructions and have uncommented the web.xml located in C:\tomcat\conf and made to servlet and servlet mapping.


I have attached the text file with my existing CLASSPATH, screenshot of where my jar files are saved, and where the location of where I am saving my files to compile.

Thank you in advance for all of your help.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlet containers such as Tomcat totally ignore your environment CLASSPATH setting.

There should be a class-loader-howto.html file in your webapps\docs path along with other useful documentation.

In order to use the "Servlet That Does Not Use Packages" you will need to have the "invoker" servlet turned on.

My advice: DON"T DO IT! - it is a conceptual dead end you will just have to unlearn.

Instead learn how to write and configure servlet classes with packages.

Bill
 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vikki,

I'm not sure If I find any attachment in your post. But the best thing is to paste the content in the thread itself. You can use "Code" button for this.

Anyways, your application path would look something like below



Typically all the applications would look similar to the above structure.

coming to your problem

I get an error message of stating that the requested resource (/servlet/HelloServlet) is not available.



I'm thinking mostly it could be a problem with your mapping in web.xml. If you could paste the contents as mentioned, some body can help you.
 
Kumar Raja
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

William Brogden wrote:Servlet containers such as Tomcat totally ignore your environment CLASSPATH setting.

There should be a class-loader-howto.html file in your webapps\docs path along with other useful documentation.

In order to use the "Servlet That Does Not Use Packages" you will need to have the "invoker" servlet turned on.

My advice: DON"T DO IT! - it is a conceptual dead end you will just have to unlearn.

Instead learn how to write and configure servlet classes with packages.

Bill



Hi Bill,

I'm just curious to know what this concept all about, not that I want to implement that but wanted to know what it is and why it was deprecated.
 
Vikki Fiawoo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What type of files can I attached. I tried attaching .txt, .doc, and .java with no such luck. So I just give up.

Here is how listed the jar files in the CLASSPATH



Here are snippets of the web.xml file saved in C:\tomcat\conf









Here is the original web.xml file saved in C:\tomcat\webapps\ROOT\WEB-INF

 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The original Tomcat authors thought it would be easier for newbies to learn servlet programming if there was a very easy way of deploying a servlet just by plunking the class in a directory and using the name of the class in a URL. No configuration web.xml, etc.

The Invoker Servlet was the tool for doing this. Read the FAQ to see why this is a bad idea.

Essentially endless confusion results when you attempt to use many features of the servlet API while still using the Invoker.

Other bad decisions of the first few servlet editions had to do with security and have largely been corrected, which is why you see deprecated methods in the API.

Bill
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic