This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

How to configure tomcat 6.0.36 in Windows 7 to deploy servlets  RSS feed

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I extracted tomcat-6.0.36 zip file to c:\tomcat, now root of my tomcat installation is c:\tomcat. I have set the CLASSPATH to

".;C:\tomcat\lib\servlet-api.jar;C:\Program Files\Java\jdk1.7.0_10"

Tomcat-6.0.36 is now running and the Home page is displayed

I created the below Servlet



The above Servlet was successfully compiled and the resulting .class file was placed in the directory /webapps/ROOT/WEB-INF/classes The classes directory was not created when the tomcat zip file was extraxted so I created it my self.Inside WEB-INF/ directory there is a web.xml file and I didn't do anything with it.

When I tried to access the Servlet HelloWorld through the url /servlet/HelloWorld the response is HTTP Status 404 - /servlet/HelloWorld

type Status report

message /servlet/HelloWorld

description The requested resource is not available. Apache Tomcat/6.0.36

trying with the url /servlets/servlet/HelloWorld resulted in the same response as above

What must be done to get the Servlets deployed? Please tell me How to modify web.xml file in the WEB-INF directory.I have referred many questions posted even on javaranch But found no solution

Thanks
 
Marshal
Posts: 67191
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Varuna Seneviratna wrote:I created the below Servlet ...


Place the servlet class in a package other than the default. Servlets in the default package may or may not work. Always put all your classes in named packages.

The above Servlet was successfully compiled and the resulting .class file was placed in the directory /webapps/ROOT/WEB-INF/classes


This is usually incorrect. Did you mean to mix your classes in with the ROOT web app? You should create a folder for your app in web apps other than ROOT, and create the WEB-INF structure in that context.

there is a web.xml file and I didn't do anything with it.


There's your problem. Make sure that your servlets and their mappings are declared in the deployment descriptor (web.xml). Otherwise, they are not loaded.

When I tried to access the Servlet HelloWorld through the url /servlet/HelloWorld the response is HTTP Status 404 - /servlet/HelloWorld


Without a mapping in web.xml, how did you think that that would work?

See the ServletsFaq for more details.
 
We begin by testing your absorbancy by exposing you to this tiny ad:
ScroogeXHTML 8.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/704747/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!