wood burning stoves 2.0*
The moose likes Servlets and the fly likes Problems setting the CLASSPATH for my servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problems setting the CLASSPATH for my servlets" Watch "Problems setting the CLASSPATH for my servlets" New topic
Author

Problems setting the CLASSPATH for my servlets

Vikki Fiawoo
Greenhorn

Joined: Oct 22, 2010
Posts: 11
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.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
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
Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

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.


Regards
KumarRaja

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 518
    
    2

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

Joined: Oct 22, 2010
Posts: 11
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
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
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
 
Consider Paul's rocket mass heater.
 
subject: Problems setting the CLASSPATH for my servlets
 
Similar Threads
Error in Servlet compilation
servlet beginner confused
'javax.servlet . * package does not exist !'
how to use the servlet in tomcat??
Error 404- not found