?
Solved

Struts 2 session

Posted on 2011-02-18
2
Medium Priority
?
971 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 800 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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 …
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

770 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