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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:25:11+00:00 2026-05-25T12:25:11+00:00

I have set a ArrayList in the Session object inside my Action class as

  • 0

I have set a ArrayList in the Session object inside my Action class as shown

public class HelloWorld implements SessionAware

{

    private Map session;

    public HelloWorld() {
    }

    public String execute() {

        List list = new ArrayList();

        list.add("One");
        list.add("One2");
        list.add("One3");
        list.add("One4");
        list.add("One5");
        list.add("One6");
        list.add("One7");

        session.put("MyList", list);

        System.out.println("Hi inside ");

        return "SUCCESS";
    }

    public void setSession(Map session) {

        this.session = (Map) session;

    }

    public Map getSession() {

        return (Map) session;

    }

}

Please tell me how can i access this Session object “MyList” inside my JSP page
I have tried this way

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Hello World</title>
</head>
<body>

    <%
        Map session = ContextAction.getContext().getSession();
    %>

</body>
</html>

But i doesn’t know whether using ContextAction is preferable or not ??
Please tell me how can i access this Session “MyList” inside my JSP

  • 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-25T12:25:11+00:00Added an answer on May 25, 2026 at 12:25 pm

    I think you mean ActionContext, not ContextAction. Either way, that’s not the way to do it. The following examples show how to iterate over the list using both OGNL (standard Struts2 way) and JSTL (standard JSP way). You can use either approach.

    Using OGNL

    <s:iterator value="%{#session.MyList}">
      <s:property/>
    </s:iterator>
    

    Using JSTL

    <c:forEach items="${sessionScope.MyList}" var="item">
      <c:out value="${item}"/>
    </c:forEach>
    

    Here’s some more information on the <s:iterator/> tag: http://struts.apache.org/2.2.3/docs/iterator.html

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

Sidebar

Related Questions

I have an object with 2 ArrayList properties. public class TestDTO { public ArrayList
I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String,
I have a command object associated with a spring form controller: public class PluginInstance
I have an arraylist set up. I have input instuctions set up too, so
I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when
I have the following annotated Hibernate entity classes: @Entity public class Cat { @Column(name
I have stored a bulk of objects in an ArrayList and I have set
I have the following Field: private IList<Modulo> modulos; and the following Property: public virtual
I have a array list like this: private ArrayList<Locations> Artist_Result = new ArrayList<Location>(); This
I have set of values, an arraylist, and i have to find duplicate keys.

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.