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 7048469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:53:45+00:00 2026-05-28T02:53:45+00:00

I want to copy int[] named idNumbers from session scope to request scope. The

  • 0

I want to copy int[] named idNumbers from session scope to request scope.
The code below doesnt work as I get null pointer exception in my controller whenever trying to retrieve attribute from request scope. I am feeling I am not either understanding the scopes or I either set the property in wrong way.

the jsp code

<c:if test="${sessionScope.idNumbers!=null}"> // this line is OK and session scope contains the idNumbers(checked)
  <% request.setAttribute("activityId", session.getAttribute("idNumbers")); %>
  <c:set var="activityId" scope="request" value="${sessionScope.idNumbers}"/>
  <form class="spanFormat" method="post" action="/blablabla">
    <p>
      <input value="Attach" type="submit" style="color: green;" />
      <input name="programId" style="display: none;" value="${blabla.programId}" />
    </p>
  </form>
</c:if>

the controller code, here I tried different approaches, but essentially the result tells that such parameter doesn’t exist in request scope when it should.

the first two give nulls(empty) and then null pointer exception:

@RequestMapping(value = "/program/set", method = RequestMethod.POST)
public String setActivitiesForProgram(@RequestParam("activityId") int[] activitiesNumbers,
        Model model, HttpSession hs, HttpServletRequest hr)
        throws ServletRequestBindingException {
    String activityNumber1 = (String) hr.getParameter("activityId");
    logger.info(activityNumber1);

    String activityNumber = (String) hr.getAttribute("activityId");
    logger.info(activityNumber);

    String[] activitiesNumbersss = (String[])    hr.getAttribute("activityId");
    logger.info(activitiesNumbersss[0]);

    String[] activitiesNumberss = hr.getParameterValues("activityId");
    logger.info(activitiesNumberss[0]);

    return "someView";
 }
  • 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-05-28T02:53:46+00:00Added an answer on May 28, 2026 at 2:53 am

    You’re setting the request attribute in the current request–not the new one made on form submission.

    Use a hidden form field filled with the session value, or just pull it from the session directly–I don’t see a compelling reason to copy it somewhere else if you already have it.

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

Sidebar

Related Questions

I want to copy a file from A to B in C#. How do
I want to copy text files and only text files from src/ to dst/
I want to copy some functions from OpenCV library to my embedded application. Rewriting
I want to copy files that have timestamps from the time the script begins
I want to copy values from one object to another object. Something similar to
I want to copy a file from /data/data... to the external SDCARD! However, i'm
I have two lists and I want to copy data from one to another
I have this code in my ActionResult public ActionResult Copy( int bvVariableid ) {
I want to copy a live production database into my local development database. Is
I want to copy the contents of a DataGridView and paste it in Excel.

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.