Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a <code>SessionAware</code> implementation, use it</p> <pre><code>private Map&lt;String, Object&gt; session; @Override public void setSession(Map&lt;String, Object&gt; session) { this.session = session; } </code></pre> <p>in the <code>execute</code> create a new collection with values and put into the session map. The problem with your code you are reusing the same variable <code>abc</code> that initially used to build the query. You should create another one and use the <code>List</code> instead of <code>Map</code> to keep the order of the items you want to iterate and display in JSP. Better to create and use the class that you should populate from the <code>ResultSet</code> and populate it into the list.</p> <pre><code>public class Market { private String marketplace; private String orderdate; private Double datamount; private Integer count; private Double result; public String getMarketplace() { return marketplace; } public void setMarketplace(String marketplace) { this.marketplace = marketplace; } public String getOrderdate() { return orderdate; } public void setOrderdate(String orderdate) { this.orderdate = orderdate; } public Double getDatamount() { return datamount; } public void setDatamount(Double datamount) { this.datamount = datamount; } public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } public Double getResult() { return result; } public void setResult(Double result) { this.result = result; } public Market(String marketplace, String orderdate, Double datamount, Integer count, Double result) { this.marketplace = marketplace; this.orderdate = orderdate; this.datamount = datamount; this.count = count; this.result = result; } } </code></pre> <p>create the property to hold the results</p> <pre><code>@Element(value = Market.class) private List&lt;Market&gt; markets = new ArrayList&lt;&gt;(); public List&lt;Market&gt; getMarkets() { return markets; } public void setMarkets(List&lt;Market&gt; markets) { this.markets = markets; } </code></pre> <p>to populate the list you should use this block, I don't know how do you use the connection, so I didn't close it. </p> <pre><code>Connection con = GetCon.getCon(); Statement statement = con.createStatement(); try { ResultSet resultset = statement.executeQuery("SELECT MarketPlace,OrderDate, ROUND(SUM(Total),2), COUNT(*) , ROUND(ROUND(SUM(Total),2)/ COUNT(*),2) FROM vend_printed WHERE OrderDate &gt;=" +newtime+ " GROUP BY OrderDate,MarketPlace") ; while(resultset.next()){ markets.add(new Market( resultset.getString(1), resultset.getString(2), resultset.getDouble(3), resultset.getInt(4), resultset.getDouble(5) )); } } finally { try { statement.close(); } catch (SQLException e) {} } </code></pre> <p>}</p> <p>now to keep the results in session</p> <pre><code>session.put("markets", markets); </code></pre> <p>in the JSP use the <code>iterator</code> tag, and you are not required to iterate the session object, just get it from action.</p> <pre><code>&lt;s:iterator value="markets"&gt; Marketplace: &lt;s:property value="marketplace" /&gt;&lt;br&gt; Orderdate: &lt;s:property value="orderdate" /&gt;&lt;br&gt; Datamount: &lt;s:property value="datamount" /&gt;&lt;br&gt; Count: &lt;s:property value="count" /&gt;&lt;br&gt; Result: &lt;s:property value="result" /&gt;&lt;br&gt; &lt;hr&gt; &lt;/s:iterator&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload