Jump to content
We've recently updated our Privacy Statement, available here ×

doubt with jsp and jaspererport


rockderick

Recommended Posts

Hello,Im trying to create a report using jsp.Does anybody knows how to pass the parameters from the request.getParameter() method from my jsp to the report.

 

Any Suggestions.

 

Here is the code Im using:

 

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

 

<%@ page import="java.util.*" %>

<%@ page import="java.io.*"%>

 

 

<%@ page import= "net.sf.jasperreports.engine.JREmptyDataSource"%>;

<%@ page import= "net.sf.jasperreports.engine.JRException"%>;

<%@ page import= "net.sf.jasperreports.engine.JasperExportManager"%>;

<%@ page import= "net.sf.jasperreports.engine.JasperFillManager"%>;

 

<%@ page import= "net.sf.jasperreports.engine.*"%>;

<%@ page import= "net.sf.jasperreports.engine.export.*"%>;

<%@ page import= "net.sf.jasperreports.engine.util.*"%>;

<%@ page import= "net.sf.jasperreports.view.*"%>;

<%@ page import= "net.sf.jasperreports.engine.xml.JRXmlLoader"%>;

<%@ page import= "net.sf.jasperreports.engine.base.JRBaseReport"%>;

<%@ page import= "net.sf.jasperreports.engine.design .*"%>;

<%@ page import= "net.sf.jasperreports.engine.data.*"%>;

 

 

 

 

<%--

The taglib directive below imports the JSTL library. If you uncomment it,

you must also add the JSTL library to the project. The Add Library... action

on Libraries node in Projects view can be used to add the JSTL 1.1 library.

--%>

<%--

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

--%>

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

 

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Scheduler</title>

</head>

<body>

 

<h1 align="center">Hora de la cita</h1>

<table align="center">

<tr>

<td>Hora de la cita: </td>

<td><%=request.getParameter("txtDate")%></td>

 

</tr>

<tr>

<td>Nombre: </td>

<td><%=request.getParameter("txtNombre")%></td>

</tr>

 

<%

 

 

JREmptyDataSource empty=new JREmptyDataSource();

JasperDesign jasperDesign;

jasperDesign = JRXmlLoader.load(application.getRealPath("/WEB-INF/reporte/classic.jrxml"));

 

JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

 

Map parameters = new HashMap();

parameters.put("hola",request.getParameter("txtDate"));

JasperPrint print = JasperFillManager.fillReport(jasperReport,parameters,empty);

JasperExportManager.exportReportToPdfFile(print, application.getRealPath("/WEB-INF/reporte/hola.pdf"));

 

 

 

 

%>

 

 

</body>

</html>

 

The report creates fine however I only see the static data via ireport

 

P.D Sorry for my bad english.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...