那就不能用session了。
将参数存到application(也就是ServletContext)中吧。

解决方案 »

  1.   

    xiao_yuer(小鱼儿) ,你所说的是否就是application对象?
    我试过了,直接用application代替所有的sesstion的getAttribute和setAttribute的地方,但是依旧是同一个application就能够读取,其他的不能,例如有两个application:
    .../webapps/App1
    .../webapps/App2
    App1中的application对象的值在App2依旧读不到
      

  2.   

    hanps(),请问何谓“序列化”?
      

  3.   

    如果你的JSP服务器是Tomcat的话,在Tomcat/conf/server.xml中必须要添加如此修改试试:
    <Context path="/App1" docBase="App1" 
             debug="0"  crossContext="true"/>
    加上crossContext属性的设置,却省为false,所以我想有可能拿不到。
      

  4.   

    o,两个webapp的jsp中的内置application对象不是同一个,所以拿不到。
    你这样试试吧:
    在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.
      

  5.   

    xiao_yuer(小鱼儿) ,我还没试你上述的方法,待会儿试,但是就有一个严重的问题,用了application以后,因为它没有setMaxInactiveInterval()或者类似的方法,导致不会到一定时间就超时,结果今天我打开,还是能认得我这个用户,过去用session的时候,我是设置了60分钟超时的,application对象有没有类似的方法使得它一定时间后自动超时?
      

  6.   

    第一个方法,“加入crossContext="true"”试过了,不行
      

  7.   

    app2中的test.jsp改为;
    <%
    ....
    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>也不行哦,惨!
      

  8.   

    application.getContext("/app1");
    String IdentityCode = (String)application.getAttribute("identitycode");这样可以了吗?
      

  9.   

    还有,在server.xml中crossContext="true"也是要加入的.
      

  10.   

    test.jsp 改为:
    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的值
      

  11.   

    sorry,server.xml里边应该是:
    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也重启过了
      

  12.   

    啊....你的server.xml中的那些都没你注释掉了.....去掉<!--和-->
      

  13.   

    在webapps中的目录就算不context也是可以找到的...但是它的crossContext为false
      

  14.   

    去掉了<!--和-->了,但是还是不行,crossContext为true也加上了!!!