• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Help getting servlet to run using Tomcat 5.5

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
tim mahoney
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
tim mahoney
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Forget Steve. Look at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic