Jump to content

(Hashmap problem)parameter field is empty


Recommended Posts


My problem is.

I want to populate the parameter values against a single key .

I created a parameter named homephone ($P{homephone})

of type String as in database values r of type char[10]


then in report design I place the same parameter on the detail section.


I tried the below code(giving an arraylist values to a single key.and then converting those arraylist values into an array and then to a string array as my parameter is of type string.

so plz have a look at the code.

and also I am attaching jrxml file for reference.


public void runReport(String databaseName, String userName, String password,String reportFile,HttpServletResponse res,HttpServletRequest req)




JasperDesign jasperDesign = JRXmlLoader.load(reportFile);


JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);


Connection jdbcConnection = DriverManager.getConnection(databaseName,userName,password);

PrintWriter out = res.getWriter();

Map hphones=new HashMap();

String name = req.getParameter("firstName");

String cb1 = req.getParameter("homeinfo");



PreparedStatement stmt = jdbcConnection.prepareStatement("select firstName, homePhone from person where firstName = ?");


ResultSet rs = stmt.executeQuery();

ArrayList names = new ArrayList();

while (rs.next()) {



Object ia[] = names.toArray();

int len=ia.length;

String[] s1=new String[len];

for(int i=0;i<ia.length;i++)


s1= ia.toString();






//String s = rs.getString("homePhone");

// hphones.put("homephone",rs.getString("homePhone"));








JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,hphones,jdbcConnection);

JRHtmlExporter exporter = new JRHtmlExporter();

Map imagesMap = new HashMap();


exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);

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

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);





[file name=ctisreport1-462ed27cef2de3dc5c0ba85b3aa7badd.jrxml size=22880]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/ctisreport1-462ed27cef2de3dc5c0ba85b3aa7badd.jrxml[/file]

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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