Solved

Struts 2 session

Posted on 2011-02-18
2
969 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

696 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