calling a java class in a servlet

Posted by kawtousse on Stack Overflow See other posts from Stack Overflow or by kawtousse
Published on 2010-06-01T14:26:14Z Indexed on 2010/06/01 14:33 UTC
Read the original article Hit count: 158

Filed under:
|

hi, in my servlet i called an instance of a class.java( a class that construct an html table) in order to create this table in my jsp.

the servlet is like the following:

String report=request.getParameter("selrep");
String datev=request.getParameter("datepicker");
String op=request.getParameter("operator");
String batch =request.getParameter("selbatch");

System.out.println("report kind was:"+report);
System.out.println("date was:"+datev);
System.out.println("operator:"+op);
System.out.println("batch:"+batch);


if(report.equalsIgnoreCase("Report Denied"))
{
    DeniedReportDisplay rd = new DeniedReportDisplay(); 
    rd.ConstruireReport();
}
else if(report.equalsIgnoreCase("Report Locked"))
{
    LockedReportDisplay rl = new LockedReportDisplay(); 
    rl.ConstruireReport();
}

request.getRequestDispatcher("EspaceValidation.jsp").forward(request, response);

in my jsp i can not display this table even empty or full.

note: exemple a class that construct denied Report has this structure:

   /*constructeur*/
                  public DeniedReportDisplay() {}

 /*Methodes*/

 @SuppressWarnings("unchecked")

                 public StringBuffer ConstruireReport()

                 { 
                     StringBuffer retour=new StringBuffer();
                     int i = 0;
                     retour.append("<table border = 1 width=900 id=sheet  align=left>");    
                     retour.append("<tr bgcolor=#0099FF>" );
                     retour.append("<label> Denied Report</label>");
                     retour.append("</tr>");                       
                     retour.append("<tr>"); 

 String[] nomCols ={"Nom","Prenom","trackingDate","activity","projectcode","WAName","taskCode","timeSpent","PercentTaskComplete","Comment"};
 //String HQL_QUERY = null;                      
  for(i=0;i< nomCols.length;i++)
  {
    retour.append(("<td bgcolor=#0066CC>")+ nomCols[i] + "</td>");

   }
  retour.append("</tr>");

     retour.append("<tr>");

                 try {

 s= HibernateUtil.currentSession();
 tx=s.beginTransaction();
 Query query = s.createQuery("select  opcemployees.Nom,opcemployees.Prenom,dailytimesheet.TrackingDate,dailytimesheet.Activity," +
   "dailytimesheet.ProjectCode,dailytimesheet.WAName,dailytimesheet.TaskCode," +
   "dailytimesheet.TimeSpent,dailytimesheet.PercentTaskComplete from  Opcemployees opcemployees,Dailytimesheet dailytimesheet  " +
   "where opcemployees.Matricule=dailytimesheet.Matricule  and dailytimesheet.Etat=3 " +
   "group by opcemployees.Nom,opcemployees.Prenom" );  


   for(Iterator it=query.iterate();it.hasNext();)
      {                                                                        
                        if(it.hasNext()){

                         Object[] row = (Object[]) it.next();


                         retour.append("<td>" +row [0]+ "</td>");//Nom
                         retour.append("<td>" + row [1] + "</td>");//Prenom
                         retour.append("<td>" + row [2] + "</td>");//trackingdate
                         retour.append("<td>"  +  row [3]+  "</td>");//activity
                         retour.append("<td>"  + row [4] +"</td>");//projectcode
                         retour.append("<td>" +  row [5]+ "</td>");//waname
                         retour.append("<td>" + row [6] + "</td>");//taskcode
                         retour.append("<td>" + row [7] + "</td>");//timespent
                         retour.append("<td>" + row [8] + "</td>");//perecnttaskcomplete
                         retour.append("<td><input type=text /></td>");//case de commentaire
                                     }
                                  retour.append("</tr>");


      }   
 //terminer la table.
                          retour.append ("</table>");

                          tx.commit();


                } catch (HibernateException e) 
                 {
     retour.append ("</table><H1>ERREUR:</H1>" +e.getMessage());
              e.printStackTrace();
                 }

                 return retour;
 }

thanks for help.

© Stack Overflow or respective owner

Related posts about java

Related posts about servlets