In JSP and Servlet, can I save a two dimensional array in the session variable?

Posted on 2006-05-08
Last Modified: 2013-11-24
So that I can pass that two dimensional array to the other page? If I can, should I implement serializable? If not, any alternate way exists?

Question by:ly_uwo
    LVL 92

    Accepted Solution

    arrays are objects so you can store them in your session:

    in[][] myarray = new int[4][5];

    session.setAttribute("name", myarray);
    LVL 1

    Assisted Solution

    You can get back from the session by type casting it to your type..
    like this

    int[][] myarray = (int [][]) session.getAttribute("name");
    LVL 30

    Assisted Solution

    >> If I can, should I implement serializable?

    I don't think that's necessary.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    The viewer will learn how to implement Singleton Design Pattern in Java.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now