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

salma.zejli

Members
  • Posts

    7
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Security Advisories

Downloads

Everything posted by salma.zejli

  1. Hello everybody, iI really need your help regarding this issue.I have found in JasperSoft embedding guide that there are newer features of the JasperReports Library that allow interactive reports where tables can be sorted or filtered by the user.I didn't found relevant information in the web related to the JasperReports Libraries (the java libraries) that I should use in order to program the retrieval of the reports in my own application.I'd like to have the possibility to retrieve the report filters as well, then apply them to filter my reports in my own application.Thanks in advance for any suggestion.
  2. I'm trying to retrieve a jasper report with RESTV1 webservices and then display it.I used this code: <%@ page import="java.io.*" %><% %><%@ page import="javax.xml.parsers.*" %><% %><%@ page import="org.w3c.dom.*" %><% %><%@ page import="org.xml.sax.*" %><% %><%@ page import="javax.xml.transform.*" %><% %><%@ page import="javax.xml.transform.dom.*" %><% %><%@ page import="javax.xml.transform.stream.*" %><% %><%@ page import="org.apache.commons.httpclient.HttpClient" %><% %><%@ page import="org.apache.commons.httpclient.HttpStatus" %><% %><%@ page import="org.apache.commons.httpclient.methods.PostMethod" %><% %><%@ page import="org.apache.commons.httpclient.methods.PutMethod" %><% %><%@ page import="org.apache.commons.httpclient.methods.GetMethod" %><% %><%@page contentType="application/pdf" %><% String serverURL = "http://pc-demo-bi:8090/jasperserver-pro/"; String reportName = "/public/folder1/1._Geographic_Results_by_Segment_Report"; String reportFormat ="pdf"; String res=null; HttpClient client = new HttpClient(); // Setting Login URL in a POST method String loginURL = serverURL+"rest/login"; PostMethod postMethod = new PostMethod(loginURL); // Set authentication parameters postMethod.addParameter("j_username", "superuser"); postMethod.addParameter("j_password", "superuser"); // Send POST with login request int statusCode = client.executeMethod(postMethod); // Check correct login process if (statusCode != HttpStatus.SC_OK) { System.out.println("Login failed: " + postMethod.getStatusLine()); return; } System.out.println("I/'m happy"); // Settting resource URL in a GET method to get descriptor String resourceURL = serverURL+"rest/resource/"+reportName; GetMethod getMethod = new GetMethod(resourceURL); // Send GET request for descriptor statusCode = client.executeMethod(getMethod); // Check correct descriptor process if (statusCode != HttpStatus.SC_OK) { System.out.println("Descriptor failed: " + getMethod.getStatusLine()); } System.out.println("I/'m much happy"); // Get the response body as String String descriptorSource = getMethod.getResponseBodyAsString(); System.out.println(descriptorSource); //Transform descriptor from String into XML Document Document descriptorXML = stringToDom(descriptorSource); // Use this method if you need to send parameters to the report // These are added to the XML Document //addParameter(descriptorXML, "personID", "1244"); // Settting PUT method to run report, the url contains the RUN_OUTPUT_FORMAT parameter String reportURL = serverURL+"rest/report/"+reportName+"?RUN_OUTPUT_FORMAT="+reportFormat; PutMethod putMethod = new PutMethod(reportURL); // Setting the request Body. The descriptor XML Document is transform to String and add to the request body. putMethod.setRequestBody(descriptorSource); // Send PUT request to execute the report. statusCode = client.executeMethod(putMethod); // Check correct report process if (statusCode != 201) { System.out.println("Report failed: " + putMethod.getStatusLine()); } System.out.println("I'm very very happy"); // Get the response body String reportSource = putMethod.getResponseBodyAsString(); System.out.println(reportSource); // Transform report information into XML Document. Document reportXML = stringToDom(reportSource); // Extrac from XML Document the report's UUID NodeList nodes = reportXML.getElementsByTagName("uuid"); String reportUuid = nodes.item(0).getTextContent(); System.out.println(reportUuid); // Setting GET request to download the report String reportFileURL = serverURL+"rest/report/"+reportUuid+"?file=report"; GetMethod getMethodFile = new GetMethod( reportFileURL ); //Send GET request to download the report statusCode = client.executeMethod(getMethodFile); // Check correct report process if (statusCode != 200) { System.out.println("Downlaod failed: " + putMethod.getStatusLine()); } System.out.println("I'm very very very happy"); /* InputStreamReader isr = new InputStreamReader(getMethodFile.getResponseBodyAsStream()); BufferedReader in = new BufferedReader(isr); String str; StringBuffer accumule = new StringBuffer(); while ((str = in.readLine()) != null) { System.out.println(str); accumule.append(str); } in.close(); res = accumule.toString(); PrintWriter writer = response.getWriter(); writer.write( res); writer.flush(); out.println(res); */ // Getting the report body InputStream is = getMethodFile.getResponseBodyAsStream(); BufferedInputStream bis = new BufferedInputStream( is ); String datastr = null; StringBuffer sb = new StringBuffer(); byte[] bytes = new byte[ 8192 ]; int count = bis.read( bytes ); while( count != -1 && count <= 8192 ){ out.print(new String(bytes, 0, count)); count = bis.read( bytes ); } bis.close(); %><%! public static Document stringToDom(String xmlSource) throws SAXException, ParserConfigurationException, IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); StringReader sr = new StringReader(xmlSource); InputSource is = new InputSource(sr); return builder.parse(is); } public static String domToString( Document xml ) throws Exception{ TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(xml), new StreamResult(writer)); return writer.getBuffer().toString().replaceAll("n|r", ""); } //Adds node like <parameter name ="exampleParm1" >value</parameter> public static void addParameter(Document doc,String name, String value){ Element element = doc.getDocumentElement(); Element node = doc.createElement("parameter"); node.setAttribute("name",name); CDATASection cdata = doc.createCDATASection(value); node.appendChild(cdata); element.appendChild(node); } %> I have succeded to display a report in html and PDF but I can't visualize it's content.The report is given in the format required but empty.Any suggestions please ?Thanks in advance
  3. I found this line in the installation.log file:[java] Imported resource /public/Samples/Reports/11g.SalesByMonthReport, but I can't see the report when I click on it.
  4. do you mean the installation.log the file which is in the installation directory of jasperserver ?
  5. Hello, I have installed jasperreport server 5.6 in Windows 8 (64 bits) and can't launch it. I receive this error:class not registered.I tried in Windows 7 (64 bits).the server is launched but I can't open reports in the sample folder.I don't know what is going wrong.Thanks in advance. Best regards
  6. Hello everybody, I'm using Spring framework with Spring Tool Suite and I'm trying to authenticate to the jasperreport server with basic authentication. I found in almost all the tutoriels that the spring security configuration file is configured like this: <user name="mkyong" password="123456" authorities="ROLE_USER" /> (in authentication manager) in the spring-security.xml file. I see that it's useful only if we develop our own application in the same project (for example) and we want to authenticate to this application.But in my case I have to authenticate to a jasperreport sever.Does it work the same in this case? Also, I see that in some cases the jdbc driver is invoked in the spring-security.xml file, but I'm connecting to a server not to a database.So, I don't think that I have to use the jdbc. The tutoriels that I found don't meet my need exactly, because they don't treat the connexion to the server, but just to some pre-developped applications or databases.So please, if you can help me with any useful tutoriels I will be thankful. Best regards
  7. Hello everybody, I created a new report with a template selected from the new report Wizard,but I realized later that I should change only the report template and keep its data. I don't want to create a new report because this operation requires a new connection to the database, which causes problems with my vertica database.Do you have any suggestion? Thanks in advance
×
×
  • Create New...