Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in context root

 
santomh Mclain
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
santomh Mclain
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic