Launching servlet in browser - error "The requested resource is not available"

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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).

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.

<?xml version="1.0" encoding="ISO-8859-1"?>
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
Welcome to Tomcat Welcome to Tomcat
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
<-- added the following for invoker servlet --> invoker org.apache.catalina.servlets.InvokerServlet
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>

The web.xml file was modified per book guide to allow locating anonymous servlets in the default directory.

Here is the context.xml file:

Code:

<!-- The contents of this file will be loaded for each web application -->
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>META-INF/context.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

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.

Re: Launching servlet in browser - error "The requested resource is not available"

Ok, I see that you are trying to write a servlet that will return an HTML page to your browser.
I haven't worked with Tomcat in a while and will have to do some research about how to configure servlets.

Re: Launching servlet in browser - error "The requested resource is not available"

Okay, I solved this problem:

As stated by Norm - the error log actually shows that line 42 of the web.xml file has an error. I examined that line and found a very stupid typo right at the beginning - the comment beginning tag that was supposed to be typed as <!-- was mistakenly typed as <-- and obviously it couldn't recognize it. Almost 3 weeks of searching in wrong places because I never would have thought to check something like this.

Re: Launching servlet in browser - error "The requested resource is not available"

The error log actually shows that line 42 of the web.xml file has an error. I examined that line and found a very stupid typo right at the beginning - the comment beginning tag was incorrect. Almost 3 weeks of searching in wrong places because I never would have thought to check something like this. Thanks nonetheless to everybody who replied, it was much appreciated!