We have a simple report that uses an Empty dataset to print certificates with the User's name and the course that they have passed.
The calling program extracts the data from the database and passes it as parameters to the report.
Seems simple.
The accented characters that are passed in are printed as 2 characters that look like they were passed in as UTF-8 and interpreted as something else.
The certificate prints the accented characters that are hardcoded in the report correctly so it is not the PDF step that is causing the problem. The rest of the portal application happily deals with French and English all the time.
What character set is Jasper Reports expecting in parameters that are passed in to JasperFillManager?
If you look at the attached certificate, the person's name is supposed to be Michaël
The following is the code.
public void printCertificate(String user_full_name, String course_title,
String request_lang, String certification_date, MessageContext ctx) {
//This debug prints out the user name and course title correctly
_log.debug("ws controller trying to print certificate with "+user_full_name+", "+
course_title +", "+
request_lang +", "+
certification_date);
PrintCertificateResponse _response = new PrintCertificateResponse();
HashMap<String, String> jasperParameter = new HashMap<String, String>();
HttpServletRequest request = (HttpServletRequest) ctx.get(AbstractHTTPDestination.HTTP_REQUEST);
String hostProtocol = request.getScheme();
String reportTemplateName;
jasperParameter.put("user_full_name", user_full_name);
jasperParameter.put("course_title", course_title);
jasperParameter.put("date", certification_date);
reportTemplateName="englishCertificate.jrxml";
String templateLocation = request.getSession().getServletContext().getRealPath("/WEB-INF/templates/"+reportTemplateName).toString();
_log.debug("templateLocation="+templateLocation);
JasperReport jasperReport;
try {
JRDataSource datasource = new JREmptyDataSource();
jasperReport = JasperCompileManager.compileReport(templateLocation);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,jasperParameter, datasource);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, baos);
_log.debug("outputstream size="+baos.size());
HttpServletResponse response = (HttpServletResponse) ctx.get(AbstractHTTPDestination.HTTP_RESPONSE);
_response.setServiceSuccess("service success");
response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out1 = response.getOutputStream();
baos.writeTo(out1);
} catch (JRException e) {
e.printStackTrace();
//_response.setServiceSuccess("service failed "+e.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}