Hi,
I use the JasperReport in my application in reason to generate some reports. I use the StreamResource to generate automatically the report.
I used this code to generate a
pdf file
:
..........
public void generatePDFreport(){
final HashMap map = new HashMap();
try {
StreamResource.StreamSource source = new StreamResource.StreamSource() {
public InputStream getStream() {
byte[] b = null;
try {
b = [b]
JasperRunManager.runReportToPdf
[/b](
MyApplication.getInstance().realpath+"/reports/allUsers.jasper", map, con);
} catch (JRException ex) {
}
return new ByteArrayInputStream(b);
}
};
StreamResource resource = new StreamResource(source, "", MyApplication.getInstance());
resource.[b]
setMIMEType("application/pdf")
[/b];
MyApplication.getInstance().getMainWindow().open(resource, "_new");
} catch (Exception ex) {
}
}
...
But now I want to generate a
HTML File
:
public void generateHTMLreport(){
final HashMap map = new HashMap();
try {
StreamResource.StreamSource source = new StreamResource.StreamSource() {
public InputStream getStream() {
byte[] b = null;
String mysource=null;
try {
b = [b]
JasperRunManager.runReportToHtmlFile
[/b](MyApplication.getInstance().realpath+"/reports/allUsers.jasper", map, con).getBytes();
} catch (JRException ex) {
}
//throw new UnsupportedOperationException("Not supported yet.");
return new ByteArrayInputStream(b);
}
};
StreamResource resource = new StreamResource(source, "", MyApplication.getInstance());
resource.[b]
setMIMEType("text/html");
[/b]
MyApplication.getInstance().getMainWindow().open(resource, "_new");
} catch (Exception ex) {
}
}
in this case, the report is generated but not displayed in my new window!!
in this new window it’s displayed the real path of the generated file!:“…wtpwebapps/myapplication/reports/allUsers.html”
cane some one tell me how can I display my generated html file???
regards