Hey, everyone! I truly hope you can help.
I am well aware there have been many, many related questions asked already about this, as well as even more answers. Unfortunately, having tried all this advice I still cannot resolve this problem.
I am trying to launch a simple
Java servlet in the browser, following instructions from the textbook:
Java Programming: Comprehensive Concepts and Techniques, Shelly Cashman Series, ISBN: 9781418859855.
I am aware of the advice given here to other people with this/similar problems, that servlets should preferably be written under a package, and not packageless, but I am following the textbook's guidance with this, and of course being a textbook, its method must work. I seek help with doing it in THIS method.
I have a Java servlet, called
HTMLBank.java which I successfully compiled with no compilation errors. Now, according to the textbook:
1) Place the .class file into C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes folder. Yes, the textbook uses the default package for this and the ROOT directory of
Tomcat.
2) Run the Tomcat service - it is running (shown as a green "play" arrow in right-bottom of the screen).
3) In the browser, type URL:
http://localhost:8080/servlet/HTMLBank and enter it. After doing this, the following error results:
HTTP Status 404 - /servlet/HTMLBank
type Status report
message /servlet/HTMLBank
description The requested resource (/servlet/HTMLBank) is not available.
Now, I might mention that I did succeed in launching a servlet once before, but that was only if I used a package, say com.example and mapped it in the web.xml file, but as stated before, this deviates from the textbook and I need to get it to work using the default package and ROOT directory.
Here is the code of the HTMLBank.java servlet file:
Here is the code of the web.xml file:
The web.xml file was modified per book guide to allow locating anonymous servlets in the default directory.
Here is the context.xml file:
This file was edited to enable servlet reloading, also as per book guide.
The following are paths to all the files/folders involved in this discussion:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes --> I created the "classes" folder, per book guide.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\classes\HTMLBank.class --> I placed the .class file into here.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\WEB-INF\web.xml --> This is the location of web.xml file which was edited.
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\context.xml is the location of the context.xml file which was edited.
So, as I said, I NEED to work the servlet without a package and from ROOT.
Please can somebody help? I greatly appreciate it!