私は自分のdaoクラスから自分のjspページにリストを取得しようとしています。
私のリストは私のDAOクラスから正常に返されますが、返されたリストを私のjspページに反復している間、テーブル列の値を取得できません
この問題を解決するために私を助けてください。
コンソールのエラー:
org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.ClassCastException: java.lang.Integer cannot be cast to
com.ebhasin.bstalentscareers.beans.Bsmostviewjp
at org.apache.jsp.jsps.BSHomePage_jsp._jspService(BSHomePage_jsp.java:594)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
------------
----------
DaoCLass.java
public List getpopularJobProvider()
{
List list = null;
try
{
session=HibernateUtil.getSessionFactory().openSession();
transaction=session.beginTransaction();
ProjectionList pl=Projections.projectionList();
pl.add(Projections.distinct(Projections.property("jobProviderId")));
list=session.createCriteria(Bsmostviewjp.class).addOrder(Order.desc("counter")).setProjection(pl).setMaxResults(4).list();
System.out.println("List of the most popular job provider in dao-"+list.size());//this is fine
transaction.commit();
}
catch (Exception e)
{
if(transaction!=null && transaction.isActive())
{
try
{
transaction.rollback();
}
catch (Exception e1)
{
System.out.println("Exception in getpopularJobProvider Rollback :" + e1);
}
}
System.out.println("Exception in getpopularJobProvider :"+e);
}
return list;
}
jspPage.jsp
<tr>
<%
List mostpopjplist=jposting.getpopularJobProvider();
Iterator mostit=mostpopjplist.iterator();
while(mostit.hasNext())
{
Bsmostviewjp bsmostviewjp=(Bsmostviewjp) mostit.next();//Problem here
Integer jpId=bsmostviewjp.getJobProviderId();
%>
<td>
<%=jpId%>
</td>
<%}%>
</tr>
Bsmostviewjp.java (Bean/pojo クラス)
import java.util.Date;
public class Bsmostviewjp implements java.io.Serializable {
private Integer mvjpId;
private int jobSeekerId;
private int jobId;
private int jobProviderId;
private int counter;
private Date appliedOn;
public Bsmostviewjp() {
}
public Bsmostviewjp(int jobSeekerId, int jobId, int jobProviderId, int counter, Date appliedOn) {
this.jobSeekerId = jobSeekerId;
this.jobId = jobId;
this.jobProviderId = jobProviderId;
this.counter = counter;
this.appliedOn = appliedOn;
}
public Integer getMvjpId() {
return this.mvjpId;
}
public void setMvjpId(Integer mvjpId) {
this.mvjpId = mvjpId;
}
public int getJobSeekerId() {
return this.jobSeekerId;
}
public void setJobSeekerId(int jobSeekerId) {
this.jobSeekerId = jobSeekerId;
}
public int getJobId() {
return this.jobId;
}
public void setJobId(int jobId) {
this.jobId = jobId;
}
public int getJobProviderId() {
return this.jobProviderId;
}
public void setJobProviderId(int jobProviderId) {
this.jobProviderId = jobProviderId;
}
public int getCounter() {
return this.counter;
}
public void setCounter(int counter) {
this.counter = counter;
}
public Date getAppliedOn() {
return this.appliedOn;
}
public void setAppliedOn(Date appliedOn) {
this.appliedOn = appliedOn;
}
}