0
I’m making a report that passes as parameters:
Start date, end date and type (which may be: in, out or in and out).
Everything works fine until I try to get the report that takes in and out... I’ve tried many ways and I can’t get results.
Query in Jasper.
Java code:
protected void relEntrada(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
SessionImplementor sim = (SessionImplementor) HibernateUtil.getSessionFactory().openSession();
Connection con = sim.connection();
String tipoMov = request.getParameter("tipMov");
String dataini = request.getParameter("dataini");
String dtini[] = dataini.split("/");
String diai = dtini[0];
String mesi = dtini[1];
String anoi = dtini[2];
String datafim = request.getParameter("datafim");
String dtfim[] = datafim.split("/");
String diaf = dtfim[0];
String mesf = dtfim[1];
String anof = dtfim[2];
HashMap param = new HashMap();
param.put("dataini", anoi +"-"+mesi+"-"+diai + " 00:00:00" );
param.put("datafim", anof +"-"+mesf+"-"+diaf + " 23:59:59" );
if (tipoMov.equalsIgnoreCase("entrada")) {
param.put("tipmov", "entrada" );
} else if(tipoMov.equalsIgnoreCase("saida")) {
param.put("tipmov", "saida" );
} //else if(tipoMov.equalsIgnoreCase("entradaesaida")) {
//param.put("tipmov", "entrada or tipo = "+'"'+"saida"+'"');
//}
InputStream arquivo = getServletContext().getResourceAsStream("/relatorios/RelMoviment.jasper");
byte[] pdf = JasperRunManager.runReportToPdf(arquivo, param ,con);
ServletOutputStream out = response.getOutputStream();
out.write(pdf);
out.flush();
} catch(Exception e) {
e.printStackTrace();
}
}