File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes problem in context root  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "problem in context root  " Watch "problem in context root  " New topic
Author

problem in context root

santomh Mclain
Greenhorn

Joined: Jun 25, 2008
Posts: 19
hi friends,

i have been using netbeans so far thats why i dont have a tight grip in the internal structure of a web application which is done automatically in netbeans IDE.

now i just want to dig out the mystery by deploying my webapplication without any IDE. so far i have organized a web application directory structure in a valid format as below

<Context Directory>/
- - - JSPs/HTML/JavaScript/CSS/Images/and all public content
<Context Directory>/WEB-INF
- - - web.xml
<Context Directory>/WEB-INF/classes
- - - All packages and class files
<Context Directory>/WEB-INF/lib
- - - All .JAR files

here Context Directory can be replaced by E:/java/OnlineExam

now the next step supposed to be done is to set the context root inside $catlina home$/conf/context.xml file. i have searched across the web to make this problem solved but still not got the solution.
please exemplify, how to set the context root and what else should i do to make entire web application deployed successfully?

tomcat version 5.5.17

context.xml



thanks in advance
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The name wouldn't be "context.xml" and it doesn't go directly in the conf directory.

Name the context fragment file after your context, with the added '.xml' extension. Then, place the file in tomcat/conf/Catalina/localhost (unless you've configured another host).

By the way, you only need to create a context fragment file if you're deploying your app from a different location than tomcat/webapps.

If you place your war file or directory structure in tomcat/webapps, then Tomcat will automatically deploy it for you.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
santomh Mclain
Greenhorn

Joined: Jun 25, 2008
Posts: 19
i am sorry i didn't elaborate it
actually this code already exist in context.xml file stored at the given location. i didn't make any changes in it.
actually i've been having this problem since long and have googled to find the solution, but the problem still exist.

it would be really helpful if you kindly write down the steps to deploy the application. rest, all that i have done already is explained.


regards
san
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Well, other than watching web.xml (something you probably don't need to do in production) there isn't anything custom in there so you could probably just get rid of it and let Tomcat autodeploy the application for you.
santomh Mclain
Greenhorn

Joined: Jun 25, 2008
Posts: 19
please be more specific how tomcat autodeploy the application....please read out the situation first and kindly tell me the solution step by step.

thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Try this (assumes you have a stock install of Tomcat on your machine).


Step #1: Download this war file to your tomcat/webapps directory.

That's it. You're done.
Go to http://localhost:8080/SimpleServlet to view the app in your browser.

You'll notice that, shortly after downloading the war file, a directory named SimpleServlet was created next to the war file.
Tomcat will recognize any folder that contains a WEB-INF folder in it as a web application.
santomh Mclain
Greenhorn

Joined: Jun 25, 2008
Posts: 19
here the scene in different,
i just want to create my own web application enviroment,organized at diffrent location than where the tomcat is installed.

at E:\java\OnlineExam,while tomcat is at C:\....\...

please suggest me how and where to set the context root so that the tomcat, installed in C drive, start configuring the web application.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I see.
Well, you should start by reading this page:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

The tomcat/conf/context.xml file is for settings that will apply to all webapps.

If you're just trying to deploy one webapp, create an xml file named after your app, plus the extension, and place it in tomcat/conf/Catalina/localhost.
You don't need the path attribute. Tomcat will use the name of the file to determine this. The docBase attribute is what you use to tell Tomcat where your app's file structure is.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in context root