using StreamResource to generate a html file

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

Here is a code example:

package com.example.streamtest;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import com.vaadin.Application;
import com.vaadin.terminal.StreamResource;
import com.vaadin.ui.Button;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;

@SuppressWarnings("serial")
public class StreamtestApplication extends Application {

    @Override
    public void init() {
        final Window mainWindow = new Window("Streamtest Application");
        final String filename = "report-" + System.currentTimeMillis()
                + ".html";
        final StreamResource stream = new StreamResource(
                new StreamResource.StreamSource() {
                    public InputStream getStream() {
                        return new ByteArrayInputStream(("<html><body><h1>"
                                + filename + "</h1></body></html>").getBytes());
                    }
                }, filename, this);
        mainWindow.addComponent(new Button("Show HTML Report",
                new Button.ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        mainWindow.open(stream, "_new");
                    }
                }));
        setMainWindow(mainWindow);
    }
}

Thanks for reply,
I do this but in the browser, I get the real path of my generated file that I want to display :frowning: But not the html
11269.png

If it is important yet, you can try:

JasperPrint print = JasperFillManager.fillReport(report, parameter, ds);
			JRHtmlExporter exporter = new JRHtmlExporter();
			final ByteArrayOutputStream output=new ByteArrayOutputStream();
			exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
			exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,output);
			exporter.exportReport();
			output.flush();
                        output.close(); 
StreamResource.StreamSource source = new StreamResource.StreamSource() {
				 
				                public InputStream getStream() {
				                   byte[] b = null;
				                    b=output.toByteArray();
				                   //throw new UnsupportedOperationException("Not supported yet.");
			                    return new ByteArrayInputStream(b);
				                }
			            };
StreamResource resource = new StreamResource(source, "TestReport.html", a);
			Embedded e = new Embedded();
			e.setMimeType("text/html");
			    e.setType(Embedded.TYPE_BROWSER);
			    e.setWidth("100%");
			    e.setHeight("400px");
			    e.setSource(resource); 
			    addComponent(e);

Will the Stream resource that pulls the data from URL connection’s input stream that is behind firewall (that is report server) be succesfullu delivered to client.
Or, is client’s request hitting report server or only Vaadin app?