Note that there are some explanatory texts on larger screens.

plurals
  1. POerror SessionMap cannot be cast to java.util.HashMap
    primarykey
    data
    text
    <p>I am trying to store my HashMap value in session and then I am retrieving it using JSP but I am receiving an error saying </p> <blockquote> <p>HTTP Status 500 - org.apache.struts2.dispatcher.SessionMap cannot be cast to java.util.HashMap</p> </blockquote> <p>Any idea why I am getting that error?</p> <pre><code>package com.action; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.text.BreakIterator; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import com.action.GetCon; public class JanuaryAction implements SessionAware{ private String name; Map abc = new HashMap(); public Map getAbc() { return abc; } public void setAbc(Map abc) { this.abc = abc; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public void setSession(Map abc) { this.abc = (HashMap) abc; } public String execute() throws Exception{ String time=getName(); /* System.out.println(time);*/ if(time.equals("January 2013")){ abc.put(time,"'2013-01-01' AND OrderDate &lt;= '2013-01-31'" ); } else if(time.equals("February 2013")){ abc.put(time,"'2013-02-01' AND OrderDate &lt;='2013-02-31'" ); } else if(time.equals("March 2013")){ abc.put(time,"'2013-03-01' AND OrderDate &lt;='2013-03-31'" ); } else if(time.equals("April 2013")){ abc.put(time,"'2013-04-01' AND OrderDate &lt;='2013-04-31'" ); } else if(time.equals("May 2013")){ abc.put(time,"'2013-05-01' AND OrderDate &lt;='2013-05-31'" ); } else if(time.equals("June 2013")){ abc.put(time,"'2013-06-01' AND OrderDate &lt;='2013-06-05'" ); } String newtime=(String)abc.get(time); /* System.out.println(newtime);*/ Connection con = GetCon.getCon(); Statement statement = con.createStatement(); 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") ; Object value = abc.remove(time); while(resultset.next()){ String marketplace = resultset.getString(1); String orderdate = resultset.getString(2); Double datamount = resultset.getDouble(3); Integer count= resultset.getInt(4); Double result=resultset.getDouble(5); abc.put(0, marketplace); abc.put(1, orderdate); abc.put(2, datamount); abc.put(3, count); abc.put(4, result);} return "success"; }} </code></pre> <p>In my JSP, I wanted to display the loop values one by one. so i am using this code now, but it is not displaying anything.</p> <pre><code>&lt;s:property value="#session.0" /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;s:property value="#session.1" /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;s:property value="#session.2" /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;s:property value="#session.3" /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt; &lt;s:property value="#session.4" /&gt;&lt;br&gt;&lt;br&gt;&lt;br&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. 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