那就不能用session了。
将参数存到application(也就是ServletContext)中吧。
将参数存到application(也就是ServletContext)中吧。
解决方案 »
- jquery 怎么实现自动填充···求解···
- 问个spring注入的问题
- svn模式下,Eclipse无法将java文件自动编译成class文件?
- 求助tomcat6 连接oracle 11g
- sun.net.smtp.SmtpClient 的问题.很简单,但是我不会
- 再问,jsp 中关于table中同名的列合并问题?急........
- jsp连接数据库提示错误怎么办
- 有关于过滤器(Filter)的问题???
- 大家给个好的分页程序(jsp)
- 急!在servlet 和 jsp 中response.sendRedirect()怎么使用相对路径??
- 加载bean的时候出了错误,牛人们帮我看看为什么
- 关于中文在jsp下的问题
我试过了,直接用application代替所有的sesstion的getAttribute和setAttribute的地方,但是依旧是同一个application就能够读取,其他的不能,例如有两个application:
.../webapps/App1
.../webapps/App2
App1中的application对象的值在App2依旧读不到
<Context path="/App1" docBase="App1"
debug="0" crossContext="true"/>
加上crossContext属性的设置,却省为false,所以我想有可能拿不到。
你这样试试吧:
在App2中去取App1的application(ServletContex)对象。
application.getContext(App1URL)方法可以取到App1的上下文环境,也就取到了其中的attributes.其中ServletContex.getContext()方法的详细说明为:
public ServletContext getContext(java.lang.String uripath)Returns a ServletContext object that corresponds to a specified URL on the server.
This method allows servlets to gain access to the context for various parts of the server, and as needed obtain RequestDispatcher objects from the context. The given path must be begin with "/", is interpreted relative to the server's document root and is matched against the context roots of other web applications hosted on this container. In a security conscious environment, the servlet container may return null for a given URL.Parameters:
uripath - a String specifying the context path of another web application in the container.
Returns:
the ServletContext object that corresponds to the named URL, or null if either none exists or the container wishes to restrict this access.
<%
....
application.getContext("http://10.10.100.5:8080/app1");
String IdentityCode = (String)application.getAttribute("identitycode");
if (IdentityCode == null){
IdentityCode = "null";
}%><html>
<body>
<%= IdentityCode %>
</body>
</html>也不行哦,惨!
String IdentityCode = (String)application.getAttribute("identitycode");这样可以了吗?
application.getContext("/app1");
String IdentityCode = (String)application.getAttribute("identitycode");server.xml里边:
<!--
<Context path="/forum" debug="0" crossContext="true" privileged="true"
docBase="/usr/local/jakarta-tomcat4.1/webapps/app1">
</Context>
--> <!--
<Context path="/NetDevelopShop" debug="0" crossContext="true" privileged
="true"
docBase="/usr/local/jakarta-tomcat4.1/webapps/app2">
</Context>
-->但是还是读不出app1的application对象的identitycode的值
server.xml里边:
<!--
<Context path="/app1" debug="0" crossContext="true" privileged="true"
docBase="/usr/local/jakarta-tomcat4.1/webapps/app1">
</Context>
--> <!--
<Context path="/app2" debug="0" crossContext="true" privileged
="true"
docBase="/usr/local/jakarta-tomcat4.1/webapps/app2">
</Context>
-->但是还是不行,tomcat也重启过了