Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

java - Tomcat context.xml files, is there a hierarchy?

I am trying to use symbolic links in one of the applications I have running on Tomcat5. Thanks to some help from another StackOverflow question I was able to do it by creating a context.xml file in

/...myapplication/META-INF/context.xml

I am now trying to implement this on a production server. However, there are other applications running on it. And there is another context file

/...tomcat/conf/context.xml

It seems to me these are setting configurations server-wide to all applications. If I allowLinks in the conf/context.xml file, my symbolic links work. If I don't allowLinks in conf/context.xml, my application's symbolic links do not work, even though I have allowed them in the META-INF/context.xml

My question is, does the conf/context.xml control all applications? If I want symbolic links to work only in one application, do I need to remove the conf/context.xml and create new context files for each application? Or is there a way I can allow symbolic links in myapplication only?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

See my answer to the "Which Tomcat 5 context file takes precedence" question.

Regarding your specific allowLinks question, the value in conf/context.xml takes precedence by default. If you say nothing in your conf/context.xml, the default value is allowLinks="false" in your conf/context.xml.

If you want to change it only for your myapplication, trying to say <Context allowLinks="true" ...> in your META-INF/context.xml will have no effect because normally the conf/context.xml setting will take precedence.

But, if you say <Context allowLinks="true" override="true" ...> in your META-INF/context.xml, then all your <Context> settings in META-INF/context.xml will be highest precedence, overriding anything in conf/context.xml.

Finally, instead of a myapplication/WEB-INF/context.xml file, I recommend using a conf/Catalina/localhost/myapplication.xml file. This technique means you can keep the contents of your WEB-INF clean, which is the guts of your webapp -- I don't like to risk mucking about in the guts of my webapp. :-)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...