This week's book giveaways are in the Cloud/Virtualization and Go forums.
We're giving away four copies each of Cloud Native Transformation: Practical Patterns for Innovation and The Go Workshop and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Tomcat 5.0.27 Http status 404 Error

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to run an example servlet using 5.0.27 and having problems.


I have downloaded Tomcat 5.0.27 and did the initial configuration. The configuration was successfully and could see the tomcat page when i say http://localhost:8080.

Now i am trying to run my own HelloWorld example servlet.

Steps

1. I created a folder called FirstProject in webapps folder for my project.

The layout is as shown

webapps
|
|-->FirstProject
|
|-> helloworldexample.html
|-> WEB-INF(folder)
|->web.xml
|->classes(folder)
|->mypackage(folder)
|->HelloWorldExample.java
|->HelloWorldExample.class

My web.xml look as shown below

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>mypackage.HelloWorldExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/HelloWorldExample</url-pattern>
</servlet-mapping>
</web-app>

And the for the application, with new 5.0.27 tomcat version , each application should have its own context file in $CATALINA_HOME/conf/catalina/localhost/.

This is as per info in the url http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html (Please note that for tomcat 5.x, unlike tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. Instead, put them in the META-INF/context.xml directory of your WAR file or the conf directory as described above)

I have created FirstProject.xml as my context file and placed in $CATALINA_HOME\conf\catalina\localhost\ and the contents are

<!--

Context configuration file for the Tomcat Administration Web App

$Id: admin.xml,v 1.3 2004/02/20 17:09:19 remm Exp $

-->


<Context path="/FirstProject" docBase="C:/Tomcat5.0/webapps/FirstProject/"
debug="0" privileged="true">

<!-- Uncomment this Valve to limit access to the Admin app to localhost
for obvious security reasons. Allow may be a comma-separated list of
hosts (or even regular expressions).
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127.0.0.1"/>
-->

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_admin_log." suffix=".txt"
timestamp="true"/>

</Context>


But when i run
http://localhost:8080/FirsProject/HelloWorldExample.
I get following error

HTTP Status 404 - /FirsProject/HelloWorldExample

--------------------------------------------------------------------------------

type Status report

message /FirsProject/HelloWorldExample

description The requested resource (/FirsProject/HelloWorldExample) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.27

Can someone please tell me what i am doing wrong. Please help.

thanks
Cheruvu
 
John Lincoln
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Solved the problem. It was context in server.xml file Even though the version i am using 5.0.27, it does supports adding context path at the end of the file.

The problem was i used forward slash instead of backward slash ...my bad

thanks
Cheruvu
 
Won't you be my neighbor? - Fred Rogers. tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!