Jump to content

Problems in a Web Report


aggelos

Recommended Posts

hi,

 

i'm doing a web application and a have to do a report, so i look the webapp sample and it was very usefull, but when i try to run it into the internet explore seems like the athchment, all the images are break...how can i solve this? :unsure:

 

 

 

this is teh code:

File reportFile = new File(application.getRealPath(archivo));

 

if (!reportFile.exists())

throw new JRRuntimeException("Error al Cargar el reporte");

 

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(

reportFile.getPath());

Map parametros = new HashMap();

int tipo_Equipo = ((Integer)

request.getAttribute("t_Equipo")).intValue();

String n_Equipo = (String)request.getAttribute("n_Equipo");

String usr = (String)

request.getSession(false).getAttribute("usr");

String pass = (String)

request.getSession(false).getAttribute("pwd");

String valor = (String)request.getAttribute("valor");

String iva = (String)request.getAttribute("iva");

Connection con = Persistencia.getInstance().demeConexion(usr, pass);

 

parametros.put("NUMERO" , n_Equipo);

parametros.put("tipo" , new BigDecimal(tipo_Equipo));

parametros.put("valor" , valor);

parametros.put("iva" , iva);

 

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,

parametros, con);

JRHtmlExporter exporter = new JRHtmlExporter();

 

session.setAttribute("reporte", jasperPrint);

session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE,

jasperPrint);

 

StringBuffer sbuffer = new StringBuffer();

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT , jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_WRITER , out);

exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI ,

"servlets/image?image=");

exporter.exportReport();

 

 

PLEASE...HELP ME...IT'S VERY URGENT:pinch:

 

THANKS,

 

Viviana

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

u r talking about this line:

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI , "servlets/image?image=");

? in the webapp sample is ../servlest...but i configured my webmodule without this...for example if i have a directory named jsp in the web module i accessed to it like jsp/X.jsp an not like ../jsp/X.jsp...so i just remove the "../" at the beginning ... but it doesn't work...:(

 

i really don't knwo how to solve it...please help me...

 

Thanks,

 

Viviana

Link to comment
Share on other sites

Study the webapp example carefully. You need to configure your web application server correctly.

 

The URL path "servlets/image" is not a path in the filesystem, it is an assignment of a servlet class.

 

See the file WEB-INF/web.xml in the example:

Code:

<servlet-mapping>
<servlet-name>ImageServlet</servlet-name>
<url-pattern>/servlets/image</url-pattern>
</servlet-mapping>

 

The servlet-name refers to the servlet class:

Code:
[code]<servlet>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>net.sf.jasperreports.j2ee.servlets.ImageServlet</servlet-class>
</servlet>

 

This class is located in WEB-INF/classes/net/sf/jasperreports/j2ee/servlets/ImageServlet.

 

Again: it looks like a missing configuration for the servlet. If you use Tomcat you can copy the existing WEB-INF directory or copy the required configuration parts and classes to the WEB-INF to your existing application. For other web application servers you may need additional steps, consult the server docs about adding a servlet.

Post edited by: Alexander Merz, at: 2006/08/29 20:02

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...