Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8280973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:52:20+00:00 2026-06-08T09:52:20+00:00

I am trying to implement a type of client-side paging, where I only display

  • 0

I am trying to implement a type of client-side paging, where I only display X records at a time, then when the client wants to see more data I display the next X records and so forth. To do this I am trying to use a session variable, but every time I examine its value it is empty. I don’t really know all that much about Spring MVC so any help would be appreciated:

@Controller
@RequestMapping(value = "/api/rest/da")
@SessionAttributes({"sessionRowKey"})
public class DAController {
    /**
     * Default constructor for DAController
     */
    public DAController() {
    }

    /**
     *  Initialize the SessionAttribute 'sessionRowKey' if it does not exist
     */
    @ModelAttribute("sessionRowKey")
    public String createSessionRowKey()
    {
        return "";
    }

Here I check if the value is empty, which is what I initialize it to, then set the value:

@RequestMapping(value = "/getModelData/{namespace}/{type}/{rowkey:[^\\.]*\\.[^\\.]*}", method = RequestMethod.GET)
public
@ResponseBody
Map<String, Map<String, String>> getModelData(String namespace,
                                              String type,
                                              String rowkey,
                                              @ModelAttribute("sessionRowKey") String sessionRowKey,
                                              HttpServletRequest request)
{
    try 
    {
        ModelType modelType = ModelType.fromString(type);
        Model model;
        if(modelType == ModelType.STATISTICAL)  //page the data
        {
            //code abstracted
            List<KeyValue> records = results_arr[30].list();

            if(sessionRowKey.equals(""))
            {
                model = modelReader.readModel(namespace, modelType, rowkey);
                request.getSession().setAttribute("sessionRowKey", records.get(0).toString());
            }
            else model = modelReader.readModel(namespace, modelType, sessionRowKey);
        }
        else
        {
            model = modelReader.readModel(namespace, modelType, rowkey);
        }
    } 
    catch (Exception e) 
    {
        logger.log(Level.ERROR, "Error in DAController.getModelData: " + e.getMessage());
    }
}

Every time that I examine the session variable it is always “”, How long does the session variable live?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:52:22+00:00Added an answer on June 8, 2026 at 9:52 am

    Instead of the @ModelAttribute annotated parameter (sessionRowKey), use an HttpSession parameter and get the sessionRowKey using this parameter. For example:

    ... HttpSession httpSession, ...
    
    ...
    
    String sessionRowKey = (String)httpSession.getAttribute("sessionRowKey");
    
    ...
    

    Note: the above is for Java EE 5 and above. For J2EE 1.4 and before use the HttpSession.getValue and HttpSession.setValue methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement an indirect download through PHP. On the client side I
I'm trying to implement client validation for my custom type, however i'm not sure
I'm trying to implement such a protocol: Client side: 1) client sends command (String)
I am trying to implement Type Hinting of PHP5 on one of my class,
I'm trying to implement a custom field type for my Symfony2 forms but for
I am trying to implement a min heap in c++ for a struct type
It's just a service locater type of pattern I am trying to implement, where
i receive the following error when trying to implement auto-complete based on edismax type.
im trying to implement simple secured client server communiction using WCF. when im launching
I am trying to implement a type of slider using jquery. However this question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.