Solved

Struts 2 session

Posted on 2011-02-18
2
959 Views
Last Modified: 2012-05-11
I have put a List in session in a Struts 2  action class  as below
session.put("alist",list);

How do I pull   this list in a  java variable  in  JSP page ?

The following does not work . Syntax error.
List temp =  #session['alist'] ;

what is the correct syntax ?
0
Comment
Question by:cofactor
2 Comments
 
LVL 47

Expert Comment

by:for_yan
Comment Utility

In this example beloow
http://www.roseindia.net/struts/struts2/struts2ajax/struts2-session.shtml
they use dot (#session.ret)

In some other places I saw sessionScope instead of session.

Unlesss someone who knows better suggest something, you could at least try this.

<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
  <head>
    <s:head theme="ajax" debug="true"/>
  </head>
  <body>
    <s:div id="loginDiv" theme="ajax">
        <h3> Your Session: <s:property value="#session.ret" /></h3>
    <div style="width: 300px;border-style: solid">
      <s:form action="AjaxTestAction"  validate="false">
        <tr>
          <td colspan="2">
            Run Test
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <s:actionerror />
            <s:fielderror />
            <s:actionmessage/>
          </td>  
          <s:textfield name="welcome1" label="WELCOME1"/>
          <s:textfield name="welcome2" label="WELCOME2"/>
          <s:submit value="Submit" theme="ajax" targets="loginDiv"
                                  notifyTopics="/AjaxTestAction"/>
        </tr>
      </s:form>
    </div>
    </s:div>
  </body>
</html>
0
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 200 total points
Comment Utility
you  can also use scriplet .

1st import the list in the jsp page
<%
List a=(List) session.getAttribute("alist");%>
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

763 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

14 Experts available now in Live!

Get 1:1 Help Now