Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

jakarta ee - What does the crossContext attribute do in Tomcat? Does it enable session sharing?

All I can find in the Tomcat 5.5 docs is:

Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. Set to false (the default) in security conscious environments, to make getContext() always return null.

I've found some forum posts that comment that setting crossContext=true also enables sharing the session object between different web applications, but I'm not able to find any official docs stating this.

Is there a relation between Servlet.getContext() and the ability to share session state between different web applications?

What does the crossContext attribute really do in Tomcat?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

You can share sessions between web applications by using a Single Sign-On Valve.

You would set crossContext=true if you wanted to share some information between different Web Applications in the same Virtual Host.

For example app1 would call:

setAttribute("name", object);

and another app could call

getContext("/app1").getAttribute("name");

to read the information. If crossContext wasn't set to true, the getContext("/app1") would have returned null.

However, the use of crossContext is both rare and potentially insecure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...