Solved

Struts 2 session

Posted on 2011-02-18
2
966 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to increase Spring boot/Tomcat max file upload size 2 134
null output 3 35
web project error add remove 1 27
jsp error 6 25
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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 video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

789 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