abaixei o iReport 3.0.0 e desenvolvi uns relatórios
e agora vou rodar esses relatórios no ambiente web
qual o jar que tenho jogar no lib para executar o .jasper
Se alguém tiver um exemplo como chama …??? vai ajudar ???
olha…
o arquivo .jar do Jasper que se encontra em seu projeto tem que ser a mesma versão do .jar que
você possui no IReport para gerar os arquivos.jasper, senão, não vai gerar o relatório
Vou postar umas classes que uso… mas to sem tempo pra explica… mas da pra te uma ideia
package mark.utils.report;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
public class ReportUtils {
public static JasperPrint fillPrint(String fnm) throws IOException, JRException {
return fillPrint(fnm, new HashMap<String, Object>());
}
public static JasperPrint fillPrint(InputStream is) throws JRException {
return fillPrint(is, new HashMap<String, Object>());
}
public static JasperPrint fillPrint(String fnm, Map<String, Object> parameters)
throws IOException, JRException {
return fillPrint(loadReport(fnm), parameters);
}
public static JasperPrint fillPrint(InputStream is, Map<String, Object> parameters)
throws JRException {
return fillPrint(loadReport(is), parameters);
}
public static JasperPrint fillPrint(JasperReport jasperReport,
Map<String, Object> parameters) throws JRException {
JasperPrint print = null;
try {
print = JasperFillManager.fillReport(jasperReport, parameters);
} catch (JRException e) {
throw new JRException(e);
}
return print;
}
public static JasperReport loadReport(String fnm) throws IOException, JRException {
File jasperFile = new File(fnm);
if (jasperFile == null || jasperFile.exists())
throw new IOException("Error reading Jasper XML file: " + fnm);
FileInputStream is = new FileInputStream(jasperFile);
JasperReport report = loadReport(is);
is.close();
return report;
}
public static JasperReport loadReport(InputStream is) throws JRException {
JasperReport report = null;
try {
report = JasperCompileManager.compileReport(is);
} catch (JRException e) {
e.printStackTrace();
throw new JRException(e);
}
return report;
}
}
Bem… eu ia posta… mas agora fui procurar a classe e nao esta no meu pendrive só em casa.
Mas a solução é criar um servlet mudar o content do response para application/pdf e enviar via Stream o relatorio