Need some help getting a basic servlet to run in my browser. I have installed tomcat on my maching and I am able to view HTML and .JSP files ok in my browser. I am stuck trying to get the server to run in my browser.ugggh. When I use the following url:http://localhost:8080/servlet/HelloServlet I get the following error: description The requested resource (/servlet/HelloServlet) is not available.
I have been following the tutorial and have looked on the web and have come to a point where I need som help. The servlet compiles fine and I placed the .class file in webapps/ROOT/WEB-INF/classes. I did not have the classes directory when I installed Tomcat, so I created the folder and placed the file in there.
Do I need to modify any environment variables with the classes folder that I created above? Any help would be greatly appreciated.
Define the servlet in your web.xml. [ April 19, 2005: Message edited by: Carol Enderlin ]
Joined: Apr 19, 2005
I read the post and do not understand what needs to be done. I have this in my web.xml. Any other suggestions?
<!-- The "invoker" servlet, which executes anonymous servlet classes --> <!-- that have not been defined in a web.xml file. Traditionally, this --> <!-- servlet is mapped to the URL pattern "/servlet/*", but you can map --> <!-- it to other patterns as well. The extra path info portion of such a --> <!-- request must be the fully qualified class name of a Java class that --> <!-- implements Servlet (or extends HttpServlet), or the servlet name --> <!-- of an existing servlet definition. This servlet supports the --> <!-- following initialization parameters (default values are in square --> <!-- brackets): --> <!-- --> <!-- debug Debugging detail level for messages logged --> <!-- by this servlet.  -->
<!-- Marty Hall: uncommented the following "servlet" entry and also the later "servlet-mapping" entry, to support DEVELOPMENT (not deployment!) use of the invoker servlet. See http://www.coreservlets.com/Apache-Tomcat-Tutorial/ --> <servlet> <servlet-name>invoker</servlet-name> <servlet-class> org.apache.catalina.servlets.InvokerServlet </servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>
Joined: Oct 10, 2000
From the FAQ,
The much better way of invoking a servlet is by providing an explicit mapping for it. This is accomplished by using a pair of tags in your web application's web.xml file. This is not the same file as mentioned above. That file was located in Tomcat's conf/ directory. This web.xml file (which you will probably need to create) will reside in your web-application's WEB-INF/ directory. For each servlet you want to call, provide a pair of tags like the following:
We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Yeah, sorry to bother you but I was running out of work and was able to briefly look at your post. You gave me a pretty good explanation. I thought it would still be here. If I new it was going to be whiped out, I would have copied and pasted your post.