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.
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.
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.
posted 8 years ago
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
Author and all-around good cowpoke
posted 8 years ago
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.