我是自己写一套分页标签,一些初始化的存在application理,不用session。
怎么获得application啊?

解决方案 »

  1.   

    application对象其实就是ServletContext, request.getSession().getServletContext()就得到application对象了
      

  2.   

    多谢,还想问下我是这样获得的:
    new HttpServletRequest().getSession().getServletContext();
    那些request什么的,是不是跟页面传递过来的是同一个对象?
      

  3.   

    这个肯定不是.! 你自己new的和浏览器给你new的能是同一个么?
      

  4.   

    怎么得到同一个对象啊?
    我刚刚那样写编译不能通过....
    说什么 Cannot instantiate the type HttpServletRequest.
      

  5.   

    TagSupport不是有个setPageContext吗.?  你都有pageContext还怕拿不到别的? 从这个对象可以直接或者间接拿到所有的servletAPI
      

  6.   

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    ServletContext application = request.getSession().getServletContext();
      

  7.   

    这个....sorry,能给个实例么?不会写~
      

  8.   

    jsp标签里从page,request,session,application各范围取值的方法| 关注Java