store variables in a jsp page scope with the spring framework

Discussion in 'Java' started by albert kao, Apr 5, 2010.

  1. albert kao

    albert kao Guest

    I want to store some variables (e.g. number of rows per table) at page
    scope in Spring framework so that each page has its own group of
    variables. What is the proper way to do that with the spring 2.5.x
    framework?

    This has compile errors.
    What is the proper way to initialize pageContext?
    import javax.servlet.jsp.PageContext;

    @Override
    public ModelAndView handleRequestInternal(HttpServletRequest request,
    HttpServletResponse response) throws Exception {

    PageContext pageContext;

    Object o = pageContext.getAttribute("com.mycompany.pageId");

    Description Resource Path Location Type
    The local variable pageContext may not have been initialized
    HwController.java /com.mycompany.monitoring.war/src/com/mycompany/
    monitoring/war line 59 Java Problem
     
    albert kao, Apr 5, 2010
    #1
    1. Advertising

  2. albert kao

    Daniel Pitts Guest

    On 4/5/2010 11:20 AM, albert kao wrote:
    > I want to store some variables (e.g. number of rows per table) at page
    > scope in Spring framework so that each page has its own group of
    > variables. What is the proper way to do that with the spring 2.5.x
    > framework?
    >
    > This has compile errors.
    > What is the proper way to initialize pageContext?
    > import javax.servlet.jsp.PageContext;
    >
    > @Override
    > public ModelAndView handleRequestInternal(HttpServletRequest request,
    > HttpServletResponse response) throws Exception {
    >
    > PageContext pageContext;
    >
    > Object o = pageContext.getAttribute("com.mycompany.pageId");
    >
    > Description Resource Path Location Type
    > The local variable pageContext may not have been initialized
    > HwController.java /com.mycompany.monitoring.war/src/com/mycompany/
    > monitoring/war line 59 Java Problem


    Are you sure you want page scope? Why not put it in the model, which
    eventually ends up in request scope for JSPs views.

    There is no page context in a Spring controller, because the Controller
    is *not* a page.

    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
     
    Daniel Pitts, Apr 7, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    9,373
    Darryl L. Pierce
    Sep 11, 2005
  2. Replies:
    0
    Views:
    511
  3. Vajra
    Replies:
    6
    Views:
    1,167
    Chris ( Val )
    Oct 8, 2007
  4. rmn190
    Replies:
    2
    Views:
    2,476
    Arne Vajhøj
    Jan 10, 2008
  5. Goldfish
    Replies:
    1
    Views:
    834
    Goldfish
    Nov 6, 2008
Loading...

Share This Page