getServletContext()
在jsp中直接就可以用
<%
application.setAttribute("key","hello");
out.println(this.getServletContext().getAttribute("key"));
%>

解决方案 »

  1.   

    楼上的,我运行你的代码,weblogic 8.1 出错信息Compilation of 'E:\bea\user_projects\ECSNDomain\.\ECSNServer\.wlnotdelete\extract\ECSNServer__appsdir_DefaultWebApp_dir_DefaultWebApp\jsp_servlet\__test.java' failed:
    --------------------------------------------------------------------------------
     E:\bea\user_projects\ECSNDomain\.\ECSNServer\.wlnotdelete\extract\ECSNServer__appsdir_DefaultWebApp_dir_DefaultWebApp\jsp_servlet\__test.java:118: cannot resolve symbol
    probably occurred due to an error in /test.jsp line 3:
    out.println(this.getServletContext().getAttribute("key"));
    --------------------------------------------------------------------------------
    Full compiler error(s):
    E:\bea\user_projects\ECSNDomain\.\ECSNServer\.wlnotdelete\extract\ECSNServer__appsdir_DefaultWebApp_dir_DefaultWebApp\jsp_servlet\__test.java:118: cannot resolve symbol
    symbol  : method getServletContext ()
    location: class jsp_servlet.__test
          out.println(this.getServletContext().getAttribute("key")); //[ /test.jsp; Line: 3]
                      ^
    1 error
    --------------------------------------------------------------------------------
    Sun Sep 19 02:44:42 GMT+08:00 2004
      

  2.   

    如果中间加一个,getServletConfig().,也就是this.getServletConfig().getServletContext() 就可以用。所以,还是回到 原来的问题。。