[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 252
  • Last Modified:

Q related to deploying web app

Hi
I need to know how to deploy my web application, not by copying it into tomcat's webapps folder.
is it possible to have my web app in D:\somefolder and tell tomcat that my app is else where ?
any hint would be appreciated
0
hoomanv
Asked:
hoomanv
  • 8
  • 6
1 Solution
 
rrzCommented:
Yes, use something like this
<Context path="/yourAppName"  docBase="D:\somefolder ">
</Context>  
add it to   the  <Host> element  of  your Tomcat's server.xml file  and restart.  Look at  
http://www.akadia.com/download/soug/tomcat/html/tomcat_server_xml.html
http://www.onjava.com/pub/a/onjava/2003/06/25/tomcat_tips.html
0
 
hoomanvAuthor Commented:
is this compatible with tomcat 5.5 ?
0
 
rrzCommented:
Tomcat 5.5 does it differently.  The context element goes in its own xml file.  For example
yourTomcatHome\conf\Catalina\localhost\yourAppName.xml  
would contain the element I posted in my first comment.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hoomanvAuthor Commented:
you mean i have to create a file named yourAppName.xml in TomcatHome\conf\Catalina\localhost\
and add this element to it ?
the problem is that what else should be added to this file ?
because currently there is no file with this name in that directory
0
 
rrzCommented:
Yes, create that file and add to that directory. The file only contains that element.  
See "A word on Contexts" at  
http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html#A%20word%20on%20Contexts
0
 
hoomanvAuthor Commented:
ok I created a HelloWorld.xml in TomcatHome\conf\Catalina\localhost\
and added <Context path="/HelloWorld"  docBase="C:\mywebapp2"></Context> to it
formerly I used to run it by http://localhost:8080/mywebapp2/HelloWorld/ (when it was in TomcatHome\webapps)
now it resides in C:\ but it doesn't work
0
 
rrzCommented:
Which resource are you trying to access ? What are you trying for URL ? Did you try  http://localhost:8080/HelloWorld/Helloworld  if the resource is HelloWorld in your web app.
0
 
rrzCommented:
Did you restart Tomcat ?
0
 
hoomanvAuthor Commented:
both of these two work if mywebapp2 reside in webapps folder
http://localhost:8080/mywebapp2/HelloWorld
http://localhost:8080/HelloWorld/Helloworld

but neither of them work if I move mywebapp2 to C:\ and also setting the Context

> Did you restart Tomcat ?
Yes
0
 
hoomanvAuthor Commented:
OK it worked
I had another mywebapp in webapps folder which had the same name HelloWorld
Thanks a lot rrz@871311
0
 
rrzCommented:
So the resource you are trying to access is HelloWorld ( a servlet ?) ?  
I don't why the second URL doen't work. It should not be working while you web app is still in the webapps folder.
0
 
rrzCommented:
Ok, good.   rrz
0
 
hoomanvAuthor Commented:
one other Q, why was it working with http://localhost:8080/mywebapp/HelloWorld
when mywebapp resided in webapps
but now that it is in C:\ it cant be run like http://localhost:8080/mywebapp/HelloWorld
instead I must use http://localhost:8080/HelloWorld/HelloWorld

which is the appropriate/standard way ?
0
 
rrzCommented:
If you want to use  
http://localhost:8080/mywebapp/HelloWorld  
then try  
<Context path="/mywebapp"  docBase="C:\mywebapp2"></Context>
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now