Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how o set context path in tomcat6

843785Sep 10 2008 — edited Sep 10 2008
Hi friends,
I am using Tomcat 6. Here i am not able to set the context path. previously in tomcat 4. we used to set the context path in server.xml(which exists under *"\Apache Group\Tomcat 4.1\conf"*). For example i am using one class named "HelloUserGenericServlet.class" which i have kept inside "*G:\J2eePractice\myapp\WEB-INF\classes*" folder and web.xml inside"*WEB-INF*". So in tomact4i used to set the context path in context.xml like " *<Context path="/myapp" docBase="E:\temp\myapp" debug="0"/>* ". But in Tomcat 6 there is no context field exists.

After going through some documents i got this point that we have to set the context path in "server.xml" in conf directory. so there i simly put this line "*<Context path="/myapp" docBase="E:\temp\myapp" debug="0"/>* . but it's not working. its throwing error"404"
So can u friends please tell me how to solve this problem?

The content of web.xml in WEB-INF directory is as follows
+"<?xml version="1.0" encoding="ISO-8859-1"?>+

+<!DOCTYPE web-app+

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

+"htp://java.sun.com/dtd/web-app_2_3.dtd">+

+<web-app>+

+<display-name>My Application</display-name>+

+<description> My Application</description>+

+<servlet>+

+<servlet-name>HeloWorldGenericServlet</servlet-name>+

+<servlet-clas>HeloWorldGenericServlet</servlet-class>+

+</servlet>+

+<servlet-mapping>+

+<servlet-name>HeloWorldGenericServlet</servlet-name>+

+<url-patern>/HeloWorldGenericServlet</url-patern>+

+</servlet-mapping>+

+</web-app>+ "

Comments

843785
the path of he class file is "E:\temp\myapp\WEB-INF\classes"
800469
I am not sure but for tomcat 6.0 you have to define caontext in $CATALINA_BASE/conf/context.xml file.

According to tomcat docs:

For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. This is because it makes modifing the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.

For more details check tomcat specification : http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 8 2008
Added on Sep 10 2008
2 comments
333 views