Solved

Struts 2 session

Posted on 2011-02-18
2
962 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
ID: 34928018

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
ID: 34928358
you  can also use scriplet .

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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
table example 4 29
arguments to jar 5 26
type mismatch (Object[] to double[] 4 25
pagenation logic how it is working in my code 1 31
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

831 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