store variables in a jsp page scope with the spring framework

A

albert kao

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
 
D

Daniel Pitts

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top