aspose file tools*
The moose likes Tomcat and the fly likes [Tomcat] Dynamic Context? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "[Tomcat] Dynamic Context?" Watch "[Tomcat] Dynamic Context?" New topic
Author

[Tomcat] Dynamic Context?

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Recently, I've changed the way I do development with Tomcat a bit. I used to write Ant deploy/undeploy/redeploy tasks and those worked great. What stunk was when I was stuck doing a bunch of JSP work and having to do a redeploy for every little CSS/Javascript change.

What I do now, is I create a context that points to my working project which is layed out just like a real deployed application. Works great with the context reloadable set to true. Problem is that when I start working on a different project, I have to go comment the context and create or uncomment the other one.

Is there anyway that I can tell tomcat to use a context on startup or something so I don't have to keep editing my server.xml? Utalizing the tomcat/conf/catalina/localhost/appname.xml context file doesn't help either. I have to go rename the context's that I want Tomcat to ignore and then rename the one I want Tomcat to load.

Thanks.


GenRocket - Experts at Building Test Data
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42648
    
  65
I'm not quite following. What prevents you from having multiple contexts, each with their own context xml file, and all laid out in the way you describe?


Ping & DNS - my free Android networking tools app
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You shouldn't have to edit server.xml at all.
Starting with version 5, Tomcat supports context fragment files which are just the context tag stored in a file named after your application.
These files are stored in {tomcat-install}/conf/Catalina/localhost.

If you remove this file for a particular application, Tomcat will undeploy that app. Likewise, putting it back, will re-deploy it.
[ December 18, 2006: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Ulf Dittmer:
I'm not quite following. What prevents you from having multiple contexts, each with their own context xml file, and all laid out in the way you describe?


Nothing, except I don't need to load 5 applications while I am working on one. You know, memory usage and all. ;)
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Ben Souther:
You shouldn't have to edit server.xml at all.
Starting with version 5, Tomcat supports context fragment files which are just the context tag stored in a file named after your application.
These files are stored in {tomcat-install}/conf/Catalina/localhost.

If you remove this file for a particular application, Tomcat will undeploy that app. Likewise, putting it back, will re-deploy it.

[ December 18, 2006: Message edited by: Ben Souther ]



Originally posted by Gregg Bolinger:
Utalizing the tomcat/conf/catalina/localhost/appname.xml context file doesn't help either. I have to go rename the context's that I want Tomcat to ignore and then rename the one I want Tomcat to load.


which I suppose I could create a script to do this and launch Tomcat, thus creating a dynamic context loader, in a sense. Just thought there might be something a bit more built in.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Missed that, sorry
[ December 18, 2006: Message edited by: Ben Souther ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I would still like to be able to load a context or specify a context at runtime with Tomcat. I know that has to be possible because when you use Intellij's IDEA webapp deployment features, I believe it does this with the exploded directory for your webapp.

So if anyone has any ideas...
 
Consider Paul's rocket mass heater.
 
subject: [Tomcat] Dynamic Context?