Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/05/2009, 09:44
jorgelo82
 
Fecha de Ingreso: abril-2009
Mensajes: 78
Antigüedad: 15 años
Puntos: 0
Problema ireports, servlet, jsp

Que tal compañeros tengo un reporte en mi aplicacion web ya compilado recibe un parámetro el problema es que cuando le doy el parámetro no me manda el pdf, alguien podría decirme que tiene mal mi código?:

Servlet
import net.sf.jasperreports.engine.*;
import java.util.*;
import java.io.*;
import ConexionBD.*;
public class RepFolioServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
File reportFile = new File(getServletContext().getRealPath("reportes/repfolio2.jasper"));
Map parameters = new HashMap();
parameters.put("Folio_solicitud", request.getParameter("Folio"));
try {
Conexion conn=new Conexion();
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath (), parameters, conn.getConexion());
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}

JSP
<form action="RepFolioServlet" method="post" class="f-wrap-1">
<fieldset>
<table border="0" cellspacing="15">
<tbody>
<tr>
<td>Folio:</td>
<td><input type="text" name="Folio" size="15"/></td>
</tr>
</tbody>
</table>
<br>
<input type="submit" value="ACEPTAR" class="f-submit"/>
<input type="reset" value="CANCELAR" class="f-submit"/>
</fieldset>
</form>

CONEXION
package ConexionBD;
import java.sql.*;
public class Conexion {
public Connection getConexion(){
Connection c=null;
try{
Class.forName("com.mysql.jdbc.Driver");
c=DriverManager.getConnection("jdbc:mysql://localhost:3306/viaticosver2","root","unitec");
}
catch(Exception e){
e.printStackTrace();
}
return c;
}
}
POR FAVOR ALGUIEN QUE ME AYUDE ES URGENTE