aspose file tools*
The moose likes Servlets and the fly likes Help getting servlet to run using Tomcat 5.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help getting servlet to run using Tomcat 5.5" Watch "Help getting servlet to run using Tomcat 5.5" New topic
Author

Help getting servlet to run using Tomcat 5.5

tim mahoney
Ranch Hand

Joined: Apr 19, 2005
Posts: 33
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 am working through the tutorial on:
http://www.coreservlets.com/Apache-Tomcat-Tutorial/#Test1

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.

Thanks
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
See other post, Topic: calling Servlet with out web.xml.

It sounds like you're basing this on the tutorial's use of the invoker servlet that has been disabled.

I just went and checked there's a FAQ on this, InvokerServlet.

Define the servlet in your web.xml.
[ April 19, 2005: Message edited by: Carol Enderlin ]
tim mahoney
Ranch Hand

Joined: Apr 19, 2005
Posts: 33
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. [0] -->

<!-- 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>
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
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:


.
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>your.package.name.HelloWorld
</servlet-class>
</servlet>
.
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
.

[ April 19, 2005: Message edited by: Carol Enderlin ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61774
    
  67

"ecupirate",

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.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
tim mahoney
Ranch Hand

Joined: Apr 19, 2005
Posts: 33
Some of the posts were removed from this post. I came into review the last post. If you posted to this before, could you please repost?

Thanks,
Tim
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I think we finished with you getting one of my examples running.
If you have any other questions or didn't get to read any of the answers, feel free to ask again.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
tim mahoney
Ranch Hand

Joined: Apr 19, 2005
Posts: 33
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.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Yea, nobody expect the disk to freeze.

In a nutshell, there is a very clear explanation of "what a context is" in the servlet spec (link in my signature).

There is also some good information in the J2EE API Doc, also in my signature.

If you get stuck on anything, there are lots of people here who are willing to help out.

-Good luck
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help getting servlet to run using Tomcat 5.5