red_ruewei 0 Light Poster

Hi all,
First, apology if we created duplicate thread. we try to find relevant topic but no luck to find match and sorry we newbie with ireport but have basic with java.

Here is my case.
We manage to read ireport generated from jsp file with below code.
The report only select all record from database.

File:cuba.jsp

<%@ page import="net.sf.jasperreports.engine.*,java.util.*,java.io.*,java.sql.*,net.sf.jasperreports.view.*,net.sf.jasperreports.design.*,net.sf.jasperreports.engine.base.JRBaseReport"%> 


Connection  conn = null;
try
{

	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/infoapps","infoappsdba","abc123");
	out.println("database conn");
	
}
catch(Exception e){
out.println(e);
}	

File f = new File(application.getRealPath("cuba.jasper"));
			
Map p = new HashMap();
	
byte[] bytes = JasperRunManager.runReportToPdf(f.getPath,p,conn);
	
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream o = response.getOutputStream();
o.write(bytes,0,bytes.length);
o.flush();
o.close();

Here the problem when we try to pass value from jsp to ireport generated.
We already fix the ireport that view based on passing value. (see attachment cuba.jrxml and cuba.jasper as sample)

Here the code that not function

<%@ page import="net.sf.jasperreports.engine.*,java.util.*,java.io.*,java.sql.*,net.sf.jasperreports.view.*,net.sf.jasperreports.design.*,net.sf.jasperreports.engine.base.JRBaseReport"%> 

int cid=1;
Connection  conn = null;
try
{

	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/infoapps","infoappsdba","abc123");
	out.println("database conn");
	
}
catch(Exception e){
out.println(e);
}	

File f = new File(application.getRealPath("cuba.jasper"));
			
Map p = new HashMap();
[B]p.put("cid",cid);	[/B]//passing value 
byte[] bytes = JasperRunManager.runReportToPdf(f.getPath,p,conn);
	
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream o = response.getOutputStream();
o.write(bytes,0,bytes.length);
o.flush();
o.close();

System Req:
1) java jdk 1.6
2) ireport 3.6.0
3) apachec tomcat 6.0.14


Hope can give suggestion and opinion. Thanks in advance.

Here link for reference example that we refer
http://www.taringa.net/posts/ebooks-tutoriales/3305461/Reportes-jsp-_-ireport-desde-Cero.html
http://www.coderanch.com/t/478129/open-source/passing-dynamic-parameter-jasper-report
http://ireport-tutorial.blogspot.com/2008/10/ireport-parameterized-report.html