In my java web application I want to print the information of a user when I enter his id, I used the plugin jasperreport with netbeans, the problem is that when I compiled and previewed the report it worked, but when I used my page html I had an empty page and this error:
java.lang.IllegalStateException: getOutputStream() has already been called for this response
page.html
<form action="info.jsp">
<input type="text" name="id" >
</form>
info.jsp
<body>
<%
int id=Integer.parseInt(request.getParameter("id"));
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
Statement st = conn.createStatement();
File reportFile = new File(application.getRealPath("//info.jasper"));
Map param=new HashMap();
param.put("id", id);
byte[]bytes=JasperRunManager.runReportToPdf(reportFile.getPath(),param,conn);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream outStream=response.getOutputStream();
outStream.write(bytes,0,bytes.length);
outStream.flush();
outStream.close();
}catch(Exception ex){
ex.printStackTrace();
}
%>