AddHeader.VI

I have a problem with the LabviewHTTPclient.lvlib:addheader.vi. It adds a header, but it is not clear the value of the header when an empty string (as described in the help file). I use it for interfacing with a RESTful Web service that requires custom headers. Now, I have to close and reopen the "connection" to get rid of the old value of the header. Furthermore, I can't replace the header: it will be postfix of new values to the old value.

Hello

According to your information, I found a CAR (corrective action request) for your problem.

Thus, our R & D is updated on this incorrect behavior.

A possible workaround is: create and destroy a client handle for each request.

You now have enough information?

Best regards

Corné Westeneng

Application engineer

NOR-Netherlands

Tags: NI Software

Similar Questions

  • 33 Firefox does not display a pdf file when using the response object

    33.0.2 Firefox does not display pdf files by using the code below in an asp.net program, that works for the previous versions of Firefox and also works with IE. I'm using the built-in pdf viewer. All my plugins are disabled.

               Dim strPDF As String
               strPDF = Session("filname")   'pdf filename
    
               Response.Clear()
               Response.ClearHeaders()
               Response.Buffer = True
               Response.ContentType = "application/pdf"
               Response.CacheControl = "Private"
               Response.AddHeader("Pragma", "no-cache")
               Response.AddHeader("Expires", "0")
               Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate")
               Response.AddHeader("Content-Disposition", "inline; filename=" + strPDF)
               Response.WriteFile(strPDF)
    
               Response.Flush()
               Response.Close()
               Response.Clear()
               Response.End()
               Session("filname") = ""
    

    What is the result of this code that Firefox receives through the headers of HTTP response if you check that the Live Http Headers extension?

  • How we prevent save as alwways .csv file adding .txt file name if I choose the action "open with?"

    My download of csv ASP page is to call:

    Response.Clear
    Response.AddHeader "content-disposition", "attachment; filename = filename.csv ".
    Response.ContentType = "Content-Type: text/csv; "charset = utf - 8"

    When I click on the link to this ASP page, appears the dialog 'Opening filename.csv' Firefox:

    filename.csv
    which is a: Text Document

    If I choose 'Open with < any Application name >' the file is always opened by the application with a .txt appended to the name of the file, which, in this case, my spreadsheet software prevents opening correctly.

    (a) how can I prevent the .txt is added the filename if the OpenWith is used?

    (b) is there a way to add a CSV type to the tools-> Options Applications Content Type list to avoid the message "which is a: Text Document"?

    This behavior does not occur in Chrome, Opera, Safari or IE.

    It was a failure of the server, not Firefox.

    ASP should have been:

    Response.ContentType = text/csv"; "charset = utf - 8"

    Fixed!

    Thank you

  • Adding network request headers

    How can I add network request header?

    QNetworkAccessManager* netManager = new QNetworkAccessManager(this);
    
                const QUrl url(urlService);
                QNetworkRequest request(url);
                request.setAttribute(QNetworkRequest::CacheLoadControlAttribute,
                        QNetworkRequest::AlwaysNetwork);
    
                request.setRawHeader("Cookie", "JSESSIONID="+sessionId);
                QNetworkReply* reply = netManager->get(request);
    
                bool result = connect(reply, SIGNAL(finished()), this,
                        SLOT(onLoginAuthenticationLoaded()));
    

    "BOLD" part is wrong, needing a fix for it.

    in android, I'm doing this

    httpGet.addHeader ("Cookie", sessionId);

     request.setRawHeader(QString("Cookie").toUtf8(),QString("JSESSIONID="+sessionId).toUtf8());
    

    SOLVED

  • The phone queue stats

    I have a client who would like the agents must be able to view the stats on their phone line, as well as the Office of the agent. Could someone point me in the right direction?

    Hello

    Therefore, here.

    The setup of the example is as follows. First of all, a few basic terms I use in the script.

    -cc - aw: it the name of the server running the script. Is the Server Admin CIM Workstation (AW) (the script pulls information from the local database (127.0.0.1) using SQL auth (it is very important: you must have mixed auth mode enabled in SQL server, if you installed AW according to Cisco docs, you should already have it activated))

    -vialia: the name of the instance of the installation of the ICM. This means, on the AW server we can see two databases CIM: vialia_awdb (information AW), vialia_hds (based on historical data). We only need first here.

    -statreader: the account name we are connecting to SQL server. This should, of course, have the necessary rights enabled for the vialia_awdb database (public and db_owner should be OK, but you can play with restrictions)

    - [email protected] / * /: the password for the above account

    -url =http://cc-aw/stats/sg_boston.asp: this is the URL of the script. Otherwise, the name of the script itself is sg_boston.asp (display of the information on the skills of Boston Group) and is saved in the C:\Inetpub\wwwroot\stats\ folder. You may need to give him the run script permission.

    -5099: is the SkillTargetID of the Group of skills that we want to see the information. It is, for example, the SkillTargetID of the skills of Boston group. You can find the SkillTargetID of all groups of skills in the vialia_awdb.dbo.Skill_Group table (try SELECT * FROM vialia_awdb.dbo.Skill_Group in Query Analyzer for the complete list)

    Very large lines in the script:

    Response.AddHeader "Refresh", "10; URL =http://cc-aw/stats/sg_boston.asp"

    This adds a header, instructing the phone to recharge the (same) script every 10 seconds.

    oConn.Open "driver = {SQL Server}; Server = 127.0.0.1; UID = statreader; pwd =[email protected] / * /; database = vialia_awdb ".

    For uid, pwd, and database values: see the explanation above.

    So please change all these values!

    It is always good to try the script in your favorite web browser. If you get an XML object with some realistic figures, so everything is OK, you can set the URL in the form of inactive URL on phones of officers.

    If you get an error message, then:

    -check if the script itself is accessible by IIS,

    -Execute permission enabled?

    -OK SQL Login?

    Have fun. And please let me know.

    P. S.

  • ADF entry Force of user and password?

    Hello!

    We use JDev 11.1.16 and I have an ADF app that works most of the time. There is a problem when users open the application in the browser and the form request not a user name / login and then when the data technology shows in the form of empty tables to users.  If we close the browser and then try again and we get a prompt for a user to connect then everything works fine. I guess the browser puts cached login information so that if we hit the page again the user does not log in... but when she does then the tables show them all empty. I was wondering fi anyone ideas on what we could try on this!  I have set to http basic security.

    -are there a way to not do things in the browser's cache?

    -is it possible to have the app always required that the connection happen?

    d ' other options ?

    Thanks in advance for any input.

    Hello

    Like normal J2EE application, must be added

    response.setHeader ("Pragma", "non-cache" "");

    response.setHeader ("Cache-Control", "non-cache, non-magasin, max - age = 0, must-revalidate");

    response.setDateHeader ("Expires", 0);

    response.addHeader ("Cache-Control", "post-check = 0, pre-check = 0");

    Please check below for reference.

    ADF Cache-Control: no-cache

    http://adfblogspot.blogspot.in/2012/07/no-cache-for-jsfjspx-page-to-avoid-use.html

    Thank you

    Amey

  • My code servlet JasperViewer report mode more download it in pdf in chrome. How to modify this code it gives only the view in JasperViewr?

    Mr President.

    My servlet code does two things

    1 see the report in JasperViewer

    2. it download it in pdf in chrome.

    How to modify this code it gives only the view in JasperViewr?

    My code is

    package esh.view;
    
    
    import esh.model.AppModuleImpl;
    
    
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    
    
    import java.util.HashMap;
    import java.util.Locale;
    import java.util.Map;
    
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.engine.xml.JRXmlLoader;
    
    
    import net.sf.jasperreports.view.JasperViewer;
    
    
    import oracle.jbo.client.Configuration;
    
    
    @WebServlet(name = "MultiReportServletJasper", urlPatterns = { "/multireportservletjasper" })
    public class MultiReportServletJasper extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
    
    
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        }
    
    
        protected Connection getConnection() {
                
                PreparedStatement st = null;
                String amDef = "esh.model.AppModule";
                String config = "AppModuleLocal";
                AppModuleImpl am = (AppModuleImpl ) Configuration.createRootApplicationModule(amDef, config);
                
                st = am.getDBTransaction().createPreparedStatement("select 1 from dual", 0);
                Connection conn = null;    
            
                try {
                    conn = st.getConnection();
                    return conn;
                } catch (SQLException e) {
                }   
            
                return null;
            }
    
    
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            String var0 = "";  
            String reportName = "";  
            try {  
                 reportName = request.getParameter("reportName");  
                } catch (Exception e) {  
                        e.printStackTrace();  
                       }  
                 response.setContentType(CONTENT_TYPE);  
                 Map parameters = new HashMap();  
                 parameters.put("format", "pdf");  
                 parameters.put("WEBDIR", getServletContext().getRealPath("/"));  
                 parameters.put("REPORT_LOCALE", new Locale("ar"));                             
                                                                                            
                 Connection conn = null;  
                 InputStream is = null;  
            try  
                {  
                 conn = getConnection();  
                 is = getServletContext().getResourceAsStream("/WEB-INF/reports/"+reportName+".jrxml");  
                              
                             
                 response.setContentType("application/pdf");  
                 response.addHeader("Content-Disposition", "attachment; filename="+reportName+".pdf");                                        
                 JasperDesign jasperDesign = JRXmlLoader.load(is);  
                 JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);  
                 JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);                      
                 JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());  
                 JasperViewer.viewReport(jasperPrint,false);                                                                                
                  conn.close();  
                }  
                   catch (Exception e) {  
                         e.printStackTrace();  
                    } finally {  
                        closeConnection(conn);  
                    try {  
                           if(is !=null){  
                              is.close();  
                         }                                                             
                } catch (Exception localException1)  
                    {  
                      }  
                }                      
        }
        
        protected static void closeConnection(Connection conn) {
                try {
                    if(conn !=null){
                       conn.close();
                    }           
                } catch (Exception ex) {
                    //  System.out.println("Developer Msg : Exception in printReport1Servlet.closeConnection()");
                }
            }
        
        
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    Concerning

    Change: response.addHeader ("Content-Disposition", "attachment; filename = "reportName +".pdf");"

    To: response.addHeader ("Content-Disposition", "inline; filename = "reportName +".pdf");"

    Browser first tries to show the PDF, and if no pdf reader is available, you will get the download dialog box.

    (and remove JasperViewer.viewReport (jasperPrint, false);  )

    Dario

  • Add image beside the import XML content

    Dear users of InDesign,

    Importing text in an InDesign template (essentially in a story).

    When I import this XML file do some tweaking with XML-rules, like adding a title.

    function AddHeading() {}

    myIdName = "AddHeading";

    This.XPath = "//phoneno [1];

    This.Apply = function (myElement, myRuleProcessor) {}

    {with (MyElement)}

    var myPhoneNo = myElement.xmlContent;

    myElement.xmlContent.insertionPoints [0] .silence = String ("phone numbers \r'");

    myPhoneNomentioning [0] .appliedParagraphStyle = app.activeDocument.paragraphStyles.item ("HeadingPhoneNo");

    }

    Returns true;

    }

    }

    What I need to do is add an Image (a phone icon) next to the additional title ("phone numbers ').

    Because everything is floating in a story, I can't have the geometric limits for this paragraph.

    Any ideas how to achieve a placement of an image in this context?

    Thank you!

    Thanks to Peter, here is the approach solve my problem:

    (adopted from pkahrel great help in this thread: Re: image of place as anchor object by finding the text...)

    function AddHeading() {}

    myIdName = "AddHeading";

    This.XPath = "//phoneno [1];

    This.Apply = function (myElement, myRuleProcessor) {}

    {with (MyElement)}

    var myPhoneNo = myElement.xmlContent;

    myElement.xmlContent.insertionPoints [0] .silence = String ("phone numbers \r'");

    myPhoneNo.words [0] .appliedParagraphStyle = app.activeDocument.paragraphStyles.item("HeadingPhoneNo");

    var anchor = myElement.storyOffset.textFrames.add ();

    var f = new File('/Users/PATHTOIMAGE/image.png');

    var f = [0,0, "10mm", "10mm"];

    var myObjectStyle = app.activeDocument.objectStyles.item ("HeadingPhoneNo");

    anchor.appliedObjectStyle = myObjectStyle;

    Anchor.contents = myElement.contents;

    anchor.geometricBounds = GB;

    Anchor.place (f);

    Anchor.fit (FitOptions.CONTENT_TO_FRAME);

    }

    Returns true;

    }

    }

  • Jasper report renders is not the PDF file on the screen in ADF

    Im getting Error : Error While Displaying Report Page : See Console for Details


    I have all of the following Jars

    (iText - 1). 2.1.7.js2

    Jackson - core - 2.) 2.1.4

    JasperReports - 3) 5.6.0

    JasperReports - graphic - themes - 4.) 5.6.0

    JasperReports - core - 5 converter.)

    JasperReports - fonts - 6.) 5.6.0

    JCommon - 7) 1.0.15

    JFreeChart-8). 1.0.13


    Error itself:


    *java.lang.ClassCastException:  net.sf.jasperreports.engine.export.DefaultExporterFilterFactory cannot be cast to net.sf.jasperreports.engine.export.ExporterFilterFactory*  

      at net
    .sf.jasperreports.engine.export.ExporterFilterFactoryUtil.getFilterFactory(Ex  porterFilterFactoryUtil.java:53)
      at net
    .sf.jasperreports.engine.JRAbstractExporter.createFilter(JRAbstractExporter.j ava:1136)
      at net
    .sf.jasperreports.engine.JRAbstractExporter.initReport(JRAbstractExporter.jav a:726)
      at net
    .sf.jasperreports.engine.export.JRGraphics2DExporter.initReport(JRGraphics2DE  xporter.java:255)
      at net
    .sf.jasperreports.engine.JRAbstractExporter.setCurrentExporterInputItem(JRAbs  tractExporter.java:567)
      at net
    .sf.jasperreports.engine.export.JRGraphics2DExporter.exportReportToGraphics2D  (JRGraphics2DExporter.java:285)
      at net
    .sf.jasperreports.engine.export.JRGraphics2DExporter.exportReport(JRGraphics2   DExporter.java:236)
      at net
    .sf.jasperreports.view.JRViewer.paintPage(JRViewer.java:2121)
      at net
    .sf.jasperreports.view.JRViewer$PageRenderer.paintComponent(JRViewer.java:227   1)
      at javax
    .swing.JComponent.paint(JComponent.java:1054)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JViewport.paint(JViewport.java:731)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paint(JComponent.java:1063)
      at javax
    .swing.JLayeredPane.paint(JLayeredPane.java:585)
      at javax
    .swing.JComponent.paintChildren(JComponent.java:887)
      at javax
    .swing.JComponent.paintToOffscreen(JComponent.java:5226)
      at javax
    .swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:   1529)
      at javax
    .swing.RepaintManager$PaintManager.paint(RepaintManager.java:1452)
      at javax
    .swing.RepaintManager.paint(RepaintManager.java:1249)
      at javax
    .swing.JComponent.paint(JComponent.java:1040)
      at java
    .awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
      at sun
    .awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
      at sun
    .awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
      at java
    .awt.Container.paint(Container.java:1967)
      at java
    .awt.Window.paint(Window.java:3877)
      at javax
    .swing.RepaintManager$3.run(RepaintManager.java:819)
      at javax
    .swing.RepaintManager$3.run(RepaintManager.java:796)
      at java
    .security.AccessController.doPrivileged(Native Method)
      at java
    .security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:7   6)
      at javax
    .swing.RepaintManager.paintDirtyRegions(RepaintManager.java:796)
      at javax
    .swing.RepaintManager.paintDirtyRegions(RepaintManager.java:769)
      at javax
    .swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:718)
      at javax
    .swing.RepaintManager.access$1100(RepaintManager.java:62)
      at javax
    .swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1677)
      at java
    .awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
      at java
    .awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
      at java
    .awt.EventQueue.access$200(EventQueue.java:103)
      at java
    .awt.EventQueue$3.run(EventQueue.java:694)
      at java
    .awt.EventQueue$3.run(EventQueue.java:692)
      at java
    .security.AccessController.doPrivileged(Native Method)
      at java
    .security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:7   6)
      at java
    .awt.EventQueue.dispatchEvent(EventQueue.java:703)
      at java
    .awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242   )
      at java
    .awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
      at java
    .awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150   )
      at java
    .awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
      at java
    .awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
      at java
    .awt.EventDispatchThread.run(EventDispatchThread.java:91)



    My bean Code:


    public class PortoflioListJasper {
      
    public PortoflioListJasper() {
      
    }

      
    public String runReportAction() {
      
    System.out.println("On ReportAction");
      
    DCIteratorBinding empIter = (DCIteratorBinding)  getBindings().get("*Iterator Name*");
      
    System.out.println("On Iterator");
      
    Integer var = (Integer)   (empIter.getCurrentRow().getAttribute("Id"));
      
    System.out.println("On Attribute");
      
    Map m = new HashMap();
      
    System.out.println("On Map EmpID");
      m
    .put("name",var );// where employeeId is a jasper report parameter
      
    System.out.println("On Map " +portfolioId);
      
    try
      
    {
      runReport
    ("Reporta.jasper", m);
      
    }
      
    catch (Exception e)
      
    {
      
    }
      
    return null;
      
    }
      
    public BindingContainer getBindings()
      
    {
      
    return   BindingContext.getCurrent().getCurrentBindingsEntry();
      
    }

      
    public Connection getDataSourceConnection(String  dataSourceName)
      
    throws Exception
      
    {
      
    Context ctx = new InitialContext();
      
    DataSource ds =   (DataSource)ctx.lookup(dataSourceName);
      
    return ds.getConnection();
      
    }

      
    private Connection getConnection()
      
    {
      
    try
      
    {
      
    System.out.println("On Connection");
      
    return getDataSourceConnection("*DataSource Name*");// datasource name should be defined in weblogic

      
    }
      
    catch (Exception e) {
      
    System.out.println("On Catch");
      e
    .printStackTrace();
      
    return null;
      
    }
      
    }


      
    public  ServletContext getContext()
      
    {
      
    return   (ServletContext)getFacesContext().getExternalContext().getContext();
      
    }
      
    public  HttpServletResponse getResponse()
      
    {
      
    return   (HttpServletResponse)getFacesContext().getExternalContext().getResponse();
      
    }
      
    public static FacesContext getFacesContext()
      
    {
      
    return FacesContext.getCurrentInstance();
      
    }
      
    public void runReport(String repPath, java.util.Map param) throws Exception
      
    {
      
    Connection conn = null;
      
    try
      
    {
      
    HttpServletResponse response = getResponse();
      
    System.out.println("Response : " +response);
      
    ServletOutputStream out = response.getOutputStream();
      response
    .setHeader("Cache-Control", "max-age=0");
      response
    .setContentType("application/octet-stream");
      
    ServletContext context = getContext();
      
    InputStream fs = context.getResourceAsStream("/Reports/"   + repPath);
      
    System.out.println("Response : " +repPath);
      
    System.out.println("Response : " +fs);

      
    JasperReport template = (JasperReport)   JRLoader.loadObject(fs);
      
    System.out.println("Template : " +template);
      template
    .setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
      conn
    = getConnection();

      
    JasperPrint print =   JasperFillManager.fillReport(template, param, conn);
      
    System.out.println("PDF" +print);
      
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
      
    JasperExportManager.exportReportToPdfStream(print, baos);


      
    System.out.println("PDF" +baos);
      out
    .write(baos.toByteArray());
      
    JasperViewer view = new JasperViewer(print,false);
      view
    .setVisible(true);
      
    System.out.println("Printed");
      out
    .flush();
      out
    .close();
      
    FacesContext.getCurrentInstance().responseComplete();

      
    }
      
    catch (Exception jex)
      
    {
      jex
    .printStackTrace();
      
    }
      
    finally
      
    {  
      close
    (conn);
      
    }
      
    }

      
    public void close(Connection con)
      
    {
      
    if (con != null)
      
    {
      
    try
      
    {
      con
    .close();
      
    }
      
    catch (Exception e)
      
    {
      
    }
      
    }
      
    }
      
    }



    @

    I want the report to display on the screen...

    Can someone tell me where Im wrong. ?

    IM I missing all jars. ?

    Help, please...

    dvohra21 Fusion Middleware Oracle Community Portal users group

    Dear

    Sorry I forgot to paste the code

    The bean code is

    package com.ash.view.backing;
    
    import java.io.ByteArrayOutputStream;
    import java.io.InputStream;
    
    import java.sql.Connection;
    
    import java.util.HashMap;
    import java.util.Map;
    
    import javax.faces.context.FacesContext;
    
    import javax.naming.Context;
    import javax.naming.InitialContext;
    
    import javax.servlet.ServletContext;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletResponse;
    
    import javax.sql.DataSource;
    
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.type.WhenNoDataTypeEnum;
    import net.sf.jasperreports.engine.util.JRLoader;
    
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCIteratorBinding;
    
    import oracle.binding.BindingContainer;
    
    public class JasperBean {
    
        public String runCustomersReport() {
            // Add event code here...
            DCIteratorBinding empIter = (DCIteratorBinding) getBindings().get("CustomerView1Iterator");
                String cusId = empIter.getCurrentRow().getAttribute("CustId").toString();
                Map m = new HashMap();
                m.put("CustId", cusId);
                try
                {
                  runReport("CustomersList.jasper", m);
                }
                catch (Exception e)
                {
                }
    
            return null;
        } 
    
        public String runSalesInvoiceReport() {
            // Add event code here...
            DCIteratorBinding sinvIter = (DCIteratorBinding) getBindings().get("SalesView1Iterator");
                String sinvId = sinvIter.getCurrentRow().getAttribute("SalId").toString();
                Map m = new HashMap();
                m.put("SalId", sinvId);
                try
                {
                  runReport("SalesInvoice.jasper", m);
                }
                catch (Exception e)
                {
                }
    
            return null;
        }
    
        public BindingContainer getBindings()
        {
          return BindingContext.getCurrent().getCurrentBindingsEntry();
        }
    
        public Connection getDataSourceConnection(String dataSourceName)
            throws Exception
          {
            Context ctx = new InitialContext();
            DataSource ds = (DataSource)ctx.lookup(dataSourceName);
            return ds.getConnection();
          }
    
        private Connection getConnection() throws Exception
        {
          return getDataSourceConnection("AshCMSConnDS");
        }
    
        public  ServletContext getContext()
          {
            return (ServletContext)getFacesContext().getExternalContext().getContext();
          }
        public  HttpServletResponse getResponse()
          {
            return (HttpServletResponse)getFacesContext().getExternalContext().getResponse();
          }
        public static FacesContext getFacesContext()
          {
            return FacesContext.getCurrentInstance();
          }
        public void runReport(String repPath, java.util.Map param) throws Exception
        {
          Connection conn = null;
          try
          {
            HttpServletResponse response = getResponse();
            ServletOutputStream out = response.getOutputStream();
            response.setHeader("Cache-Control", "max-age=0");
            response.setContentType("application/pdf");
            ServletContext context = getContext();
            InputStream fs = context.getResourceAsStream("/reports/" + repPath);
            JasperReport template = (JasperReport) JRLoader.loadObject(fs);
            template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
            conn = getConnection();
            JasperPrint print = JasperFillManager.fillReport(template, param, conn);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            JasperExportManager.exportReportToPdfStream(print, baos);
            out.write(baos.toByteArray());
            out.flush();
            out.close();
            FacesContext.getCurrentInstance().responseComplete();
          }
          catch (Exception jex)
          {
            jex.printStackTrace();
          }
          finally
          {
            close(conn);
          }
        }
    
        public void close(Connection con)
         {
           if (con != null)
           {
             try
             {
               con.close();
             }
             catch (Exception e)
             {
             }
           }
         }
    }
    

    The servlet code is

    package com.ash.view;
    
    import com.ash.model.AppModuleImpl;
    
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    
    import java.util.HashMap;
    import java.util.Locale;
    import java.util.Map;
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.engine.xml.JRXmlLoader;
    
    import oracle.jbo.client.Configuration;
    
    @WebServlet(name = "MultiReportServlet", urlPatterns = { "/multireportservlet" })
    public class MultiReportServlet extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
    
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        }
    
        protected Connection getConnection() {
    
            PreparedStatement st = null;
            String amDef = "com.ash.model.AppModule";
            String config = "AppModuleLocal";
            AppModuleImpl am = (AppModuleImpl ) Configuration.createRootApplicationModule(amDef, config);
    
            st = am.getDBTransaction().createPreparedStatement("select 1 from dual", 0);
            Connection conn = null;    
    
            try {
                conn = st.getConnection();
                return conn;
            } catch (SQLException e) {
            }   
    
            return null;
        }
    
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                      String var0 = "";
                      String reportName = "";
                      try {
                          reportName = request.getParameter("reportName");
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                      response.setContentType(CONTENT_TYPE);
                      Map parameters = new HashMap();
                             parameters.put("format", "pdf");
                             parameters.put("WEBDIR", getServletContext().getRealPath("/"));
                             parameters.put("REPORT_LOCALE", new Locale("ar"));  
    
                             if(reportName.equals("CustomersList"))
                             {
                                 Object value1 = request.getParameter("value1");
                                 parameters.put("p1", value1);  
    
                             }  
    
                          if(reportName.equals("SalesInvoice"))
                          {
                              Object value1 = request.getParameter("value1");
                              parameters.put("p1", value1);  
    
                          }  
    
                             Connection conn = null;
                             InputStream is = null;
                             try
                             {
                               conn = getConnection();
                               is = getServletContext().getResourceAsStream("/WEB-INF/reports/"+reportName+".jrxml");  
    
                               response.setContentType("application/pdf");
                               response.addHeader("Content-Disposition", "attachment; filename="+reportName+".pdf");  
    
                               JasperDesign jasperDesign = JRXmlLoader.load(is);
                               JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
                               JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
                               JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());  
    
                               conn.close();
                             }
                             catch (Exception e) {
                               e.printStackTrace();
                             } finally {
                               closeConnection(conn);
                               try {
                                   if(is !=null){
                                       is.close();
                                   }                     
    
                               } catch (Exception localException1)
                               {
                               }
                             }                      
    
                  }
        protected static void closeConnection(Connection conn) {
            try {
                if(conn !=null){
                    conn.close();
                }
            } catch (Exception ex) {
                //  System.out.println("Developer Msg : Exception in printReport1Servlet.closeConnection()");
            }
        }
    }
    

    I use three files in lib jasper

    iText - 2.1.7

    JasperReports - 4.0.1

    JasperReports-fonts - 4.0.1

    This code displays the report in adobe reader only and in the browser like firefox after some adjustments in the browser.

    Concerning

  • Control browser caching

    Hello

    I have the problem that when the redeployment of an application where the images or js changed these changes appear not due to browser caching.

    I'm looking for is a way to disable is cached in the browser or be able to clear items cached.

    I tried the following:

    1. replace the phaselistener with the following and added to the faces lifecycle:

    public void beforePhase (PhaseEvent event)
    {
    FacesContext facesContext = event.getFacesContext ();
    HttpServletResponse response = (HttpServletResponse) facesContext
    .getExternalContext (m:System.NET.FtpWebRequest.GetResponse ());
    response.addHeader ("Pragma", "non-cache" "");
    response.addHeader ("Cache-Control", "non-cache");
    Stronger according to blog comment below which references the HTTP specifications
    response.addHeader ("Cache-Control", "non-magasin");
    response.addHeader ("Cache-Control", "must-revalidate");
    a date in the past
    response.addHeader ("Cache-Control" "max - age = 1");
    }

    These options of cathing seems not to apply to images and js.

    2 adding filters by adding to the web.xml file

    < filter >

    < name of filter > ACF < / filter-name >

    > class filter < oracle.adf.view.rich.webapp.AdfFacesCachingFilter < / class filter >

    < / filter >

    < filter mapping >

    < name of filter > ACF < / filter-name >

    < url-pattern > * < / url-pattern >

    < / filter-mapping >

    That doesn't seem to change the Cache-Control:public to Cache-Control:public, max - age = 99999, for me, it is probably somewhat good approach.

    Then, I added the cache rules to the adf-config. XML but they do not seem to override the defaults and I still get just the cache-control: public, max - age = 99999. The images are stille caches and does not change without clearing the cache of the browser!

    Here's my adf - config.xml:

    <? XML version = "1.0" encoding = "UTF-8"? >

    " < adf-config xmlns =" http://xmlns.Oracle.com/ADF/config "xmlns:config =" http://xmlns.Oracle.com/bc4j/configuration " "

    ' xmlns:adf = ' http://xmlns.Oracle.com/ADF/config/properties "> "

    " < adf-adfm-config xmlns =" http://xmlns.Oracle.com/ADFM/config "> "

    " <-rules of caching xmlns =" http://xmlns.Oracle.com/ADF/faces/rich/ACF "> "

    < rule of caching id = "cache_png" >

    false < cache > < / cache >

    false < compress > < / compress >

    < duration > 1 < / time >

    > agent caching < false < / caching agent >

    *.PNG < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule of caching id = "cache_css" >

    < duration > 1 < / time >

    > agent caching < false < / caching agent >

    *.CSS < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule of caching id = "cache_js" >

    < duration > 1 < / time >

    > agent caching < false < / caching agent >

    *.js < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule of caching id = "cache_jpg" >

    false < cache > < / cache >

    false < compress > < / compress >

    < duration > 1 < / time >

    > agent caching < false < / caching agent >

    *.jpg < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule of caching id = "cache_jpeg" >

    false < cache > < / cache >

    false < compress > < / compress >

    < duration > 1 < / time >

    > agent caching < false < / caching agent >

    *.JPEG < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule of caching id = "cache_gif" >

    false < cache > < / cache >

    false < compress > < / compress >

    < duration > 1 < / time >

    > agent caching < false < / caching agent >

    *.gif < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < caching rule id = "cache_html" >

    < compress > true < / compress >

    < duration > 1 < / time >

    > agent caching < false < / caching agent >

    *.html < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule id of caching = "cache css" >

    < duration > 4 < / time >

    > agent caching < true < / caching agent >

    *.CSS < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule id of caching = "js cache" >

    < duration > 4 < / time >

    > agent caching < true < / caching agent >

    *.js < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule id of caching = "cache png" >

    false < compress > < / compress >

    < duration > 4 < / time >

    > agent caching < true < / caching agent >

    *.PNG < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule id of caching = "cache jpg" >

    false < compress > < / compress >

    < duration > 4 < / time >

    > agent caching < true < / caching agent >

    *.jpg < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule id of caching = "cache jpeg" >

    false < compress > < / compress >

    < duration > 4 < / time >

    > agent caching < true < / caching agent >

    *.JPEG < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule id of caching = "gif cache" >

    false < compress > < / compress >

    < duration > 4 < / time >

    > agent caching < true < / caching agent >

    *.gif < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < rule id of caching = "html cache" >

    < compress > true < / compress >

    < duration > 4 < / time >

    > agent caching < true < / caching agent >

    *.html < cache-key-template > < / cache-key-model >

    < / cache-rule >

    < / cache-rules >

    < default changeEventPolicy = "ppr" useBindVarsForViewCriteriaLiterals = "true" useBindValuesInFindByKey = "true".

    mapNegativeScaleToIntegerTypes = "true" executeEmptyOnException = "true" / >

    < startup >

    < amconfig-overrides >

    < config:Database jbo.locking.mode="optimistic"/ >

    < / amconfig-overrides >

    < / boot >

    < / adf-adfm-config >

    " < adf:adf - properties-child xmlns =" http://xmlns.Oracle.com/ADF/config/properties "> "

    < name of the adf-property = value = "Application1.asd" / "adfAppUID" >

    < / adf:adf - properties-child >

    < / adf-config >

    I also tried to move the rules outside of < / adf-adfm-config > but with the same result.

    I use Jdev. 12.1.2.0.0.

    Its really important that the js and images are refreshed after a redeployment users shouldn't clear it cached so that the application can run.

    TIA

    Here's a similar approach, but with servlet filter, then you can try:

    http://StackOverflow.com/questions/8259286/disabling-browser-cache-JSF

  • We need a separate servlet class to open a report of jasper for each button in report or not?

    Mr President.

    We need a separate servlet class to open a report of jasper for each button in report or not?

    My code for the servlet is as under which works very well for a single report.

    package ash.view;
    
    
    import ash.model.SchoolAppModuleImpl;
    
    
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    
    
    import java.util.HashMap;
    import java.util.Locale;
    import java.util.Map;
    
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.engine.xml.JRXmlLoader;
    
    
    import oracle.jbo.client.Configuration;
    
    
    @WebServlet(name = "ReportServlet", urlPatterns = { "/reportservlet" })
    public class ReportServlet extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
    
    
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        }
        
        protected Connection getConnection() {
            
            PreparedStatement st = null;
            String amDef = "ash.model.SchoolAppModule";
            String config = "SchoolAppModuleLocal";
            SchoolAppModuleImpl am = (SchoolAppModuleImpl ) Configuration.createRootApplicationModule(amDef, config);
            
            st = am.getDBTransaction().createPreparedStatement("select 1 from dual", 0);
            Connection conn = null;    
        
            try {
                conn = st.getConnection();
                return conn;
            } catch (SQLException e) {
            }   
        
            return null;
        }
    
    
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            String var0 = "";
            try {
                var0 = request.getParameter("classId");
            } catch (Exception e) {
                e.printStackTrace();
            }
            response.setContentType(CONTENT_TYPE);
            Map parameters = new HashMap();
                   parameters.put("format", "pdf");
                   parameters.put("WEBDIR", getServletContext().getRealPath("/"));
                   parameters.put("REPORT_LOCALE", new Locale("ar"));
            
            
                   parameters.put("classId", new String(var0));
                   Connection conn = null;
                   InputStream is = null;
                   try
                   {
                     conn = getConnection();
                     is = getServletContext().getResourceAsStream("/WEB-INF/reports/ClassDataReport.jrxml");
            
            
                     response.setContentType("application/pdf");
                     response.addHeader("Content-Disposition", "attachment; filename=ClassDataReport.pdf");
                      
                     JasperDesign jasperDesign = JRXmlLoader.load(is);
                     JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
                     JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);                    
                     JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
                              
                     conn.close();
                   }
                   catch (Exception e) {
                     e.printStackTrace();
                   } finally {
                     closeConnection(conn);
                     try {
                         if(is !=null){
                             is.close();
                         }                   
                        
                     } catch (Exception localException1)
                     {
                     }
                   }
            
            PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head><title>ReportServlet</title></head>");
            out.println("<body>");
            out.println("<p>The servlet has received a GET. This is the reply.</p>");
            out.println("</body></html>");
            out.close();
        }
        
        protected static void closeConnection(Connection conn) {
            try {
                if(conn !=null){
                    conn.close();
                }           
            } catch (Exception ex) {
                //  System.out.println("Developer Msg : Exception in printReport1Servlet.closeConnection()");
            }
        }
    }
    

    Concerning

    It will be something like this:

      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              String var0 = "";
              String reportName = "";
              try {
                  reportName = request.getParameter("reportName");
              } catch (Exception e) {
                  e.printStackTrace();
              }
              response.setContentType(CONTENT_TYPE);
              Map parameters = new HashMap();
                     parameters.put("format", "pdf");
                     parameters.put("WEBDIR", getServletContext().getRealPath("/"));
                     parameters.put("REPORT_LOCALE", new Locale("ar"));
    
                     if(reportName.equals("report1"))
                     {
                       var0 = request.getParameter("classId");
                       parameters.put("classId", new String(var0));
                     }
    
                     if(reportName.equals("report2"))
                     {
                       Object value1 = request.getParameter("value1");
                       Object value2= request.getParameter("value2");
                       parameters.put("p1", value1);
                       parameters.put("p2", value2);
                     }
    
                     Connection conn = null;
                     InputStream is = null;
                     try
                     {
                       conn = getConnection();
                       is = getServletContext().getResourceAsStream("/WEB-INF/reports/"+reportName+".jrxml");
    
                       response.setContentType("application/pdf");
                       response.addHeader("Content-Disposition", "attachment; filename="+reportName+".pdf");
    
                       JasperDesign jasperDesign = JRXmlLoader.load(is);
                       JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
                       JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
                       JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
    
                       conn.close();
                     }
                     catch (Exception e) {
                       e.printStackTrace();
                     } finally {
                       closeConnection(conn);
                       try {
                           if(is !=null){
                               is.close();
                           }                   
    
                       } catch (Exception localException1)
                       {
                       }
                     }
    
              PrintWriter out = response.getWriter();
              out.println("");
              out.println("ReportServlet");
              out.println("");
              out.println("

    The servlet has received a GET. This is the reply.

    "); out.println(""); out.close(); }

    And the button that will call the report should be something like this;

    
    
    
    
  • What is this java.lang.NumberFormatException: null

    Mr President.

    I'm trying to run a report with a button on a page jsff

    My button code is

    <af:button text="button 1" id="b1" destination="/printreportservlet?employeeId#{bindings.EmployeeId.inputValue}"/>
    

    My servlet code is

    package view;
    
    
    import java.io.IOException;
    import java.io.PrintWriter;
    
    
    import javax.servlet.*;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.*;
    import java.io.IOException;
    import java.io.InputStream;
    
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    
    
    import java.util.HashMap;
    import java.util.Locale;
    import java.util.Map;
    
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    
    
    
    import model.AppModuleImpl;
    
    
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.engine.xml.JRXmlLoader;
    
    
    import oracle.jbo.client.Configuration;
    
    
    @WebServlet(name = "PrintReportServlet", urlPatterns = { "/printreportservlet" })
    public class PrintReport1Servlet extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
    
    
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        }
        
        /**
                 * @return
                 */
                protected Connection getConnection() {
         
         
        //            System.out.println("getConnection--");
         
         
                    PreparedStatement st = null;
                    String amDef = "sa.gov.rgr.model.module.AppModuleAM";
                    String config = "AppModuleAMLocal";
                    AppModuleImpl am = (AppModuleImpl ) Configuration.createRootApplicationModule(amDef, config);
         
         
                    st = am.getDBTransaction().createPreparedStatement("select 1 from dual", 0);
                    Connection conn = null;
         
         
                    try {
                        conn = st.getConnection();
                        return conn;
                    } catch (SQLException e) {
                    }
         
         
                    return null;
                }
        /**
             * @param request
             * @param response
             * @throws ServletException
             * @throws IOException
             */    
    
    
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            response.setContentType(CONTENT_TYPE);
            PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head><title>PrintReportServlet</title></head>");
            out.println("<body>");
            out.println("<p>The servlet has received a GET. This is the reply.</p>");
            out.println("</body></html>");
            out.close();
            
            String var0 = "";
                    try {
                        var0 = request.getParameter("employeeId");
                       
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                   
                    response.setContentType(CONTENT_TYPE);
                   
                    Map parameters = new HashMap();
                    parameters.put("format", "pdf");
                    parameters.put("WEBDIR", getServletContext().getRealPath("/"));
                    parameters.put("REPORT_LOCALE", new Locale("ar"));
             
             
                    parameters.put("employeeId", new Long(var0));
                    Connection conn = null;
                    InputStream is = null;
                    try
                    {
                      conn = getConnection();
                      is = getServletContext().getResourceAsStream("/WEB-INF/reports/Report.jrxml");
             
             
                      response.setContentType("application/pdf");
                      response.addHeader("Content-Disposition", "attachment; filename=report.pdf");
                       
                      JasperDesign jasperDesign = JRXmlLoader.load(is);
                      JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
             
             
                      JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
             
             
                      JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
                       
             
                      conn.close();
                    }
                    catch (Exception e) {
                      e.printStackTrace();
                    } finally {
                      closeConnection(conn);
                      try {
                          if(is !=null){
                              is.close();
                          }
                         
                         
                      } catch (Exception localException1)
                      {
                      }
                    }
                   
                }
        
        /**
             * @param conn
             */
            protected static void closeConnection(Connection conn) {
                try {
                    if(conn !=null){
                        conn.close();
                    }
                   
                } catch (Exception ex) {
                    //  System.out.println("Developer Msg : Exception in printReport1Servlet.closeConnection()");
                }
            }
        
    }
    

    The code of my report is

    <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Report" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1100e657-82b6-466e-b6eb-58efd82952cb">
      <property name="ireport.zoom" value="1.0"/>
      <property name="ireport.x" value="0"/>
      <property name="ireport.y" value="0"/>
      <parameter name="employeeId" class="java.lang.String">
      <defaultValueExpression><![CDATA[]]></defaultValueExpression>
      </parameter>
      <queryString>
      <![CDATA[select * from employees
    WHERE EMPLOYEE_ID=to_number($P{employeeId})]]>
      </queryString>
      <field name="EMPLOYEE_ID" class="java.lang.Long"/>
      <field name="FIRST_NAME" class="java.lang.String"/>
      <field name="LAST_NAME" class="java.lang.String"/>
      <field name="EMAIL" class="java.lang.String"/>
      <field name="PHONE_NUMBER" class="java.lang.String"/>
      <field name="HIRE_DATE" class="java.sql.Timestamp"/>
      <field name="JOB_ID" class="java.lang.String"/>
      <field name="SALARY" class="java.math.BigDecimal"/>
      <field name="COMMISSION_PCT" class="java.math.BigDecimal"/>
      <field name="MANAGER_ID" class="java.math.BigDecimal"/>
      <field name="DEPARTMENT_ID" class="java.math.BigDecimal"/>
      <background>
      <band splitType="Stretch"/>
      </background>
      <title>
      <band height="79" splitType="Stretch"/>
      </title>
      <pageHeader>
      <band height="35" splitType="Stretch"/>
      </pageHeader>
      <columnHeader>
      <band height="61" splitType="Stretch">
      <staticText>
      <reportElement x="229" y="2" width="100" height="20" uuid="225ce4a1-d66e-4b64-bcb8-f35994d570ec"/>
      <text><![CDATA[EMPLOYEE_ID]]></text>
      </staticText>
      </band>
      </columnHeader>
      <detail>
      <band height="125" splitType="Stretch">
      <textField>
      <reportElement x="229" y="55" width="100" height="20" uuid="a8cd9d36-884a-4edf-8052-314b484e00c4"/>
      <textFieldExpression><![CDATA[$F{EMPLOYEE_ID}]]></textFieldExpression>
      </textField>
      </band>
      </detail>
      <columnFooter>
      <band height="45" splitType="Stretch"/>
      </columnFooter>
      <pageFooter>
      <band height="54" splitType="Stretch"/>
      </pageFooter>
      <summary>
      <band height="42" splitType="Stretch"/>
      </summary>
    </jasperReport>
    

    And my page jsff code is

    <?xml version='1.0' encoding='UTF-8'?>
    <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                    xmlns:f="http://java.sun.com/jsf/core">
      
      <af:button text="button 1" id="b1" destination="/printreportservlet?employeeId#{bindings.EmployeeId.inputValue}"/>
      <af:table value="#{bindings.EmployeesView1.collectionModel}" var="row" rows="#{bindings.EmployeesView1.rangeSize}"
                emptyText="#{bindings.EmployeesView1.viewable ? 'No data to display.' : 'Access Denied.'}"
                rowBandingInterval="0" selectedRowKeys="#{bindings.EmployeesView1.collectionModel.selectedRow}"
                selectionListener="#{bindings.EmployeesView1.collectionModel.makeCurrent}" rowSelection="single"
                fetchSize="#{bindings.EmployeesView1.rangeSize}" id="t1">
        <af:column headerText="#{bindings.EmployeesView1.hints.EmployeeId.label}" id="c1">
          <af:outputText value="#{row.EmployeeId}" shortDesc="#{bindings.EmployeesView1.hints.EmployeeId.tooltip}" id="ot1">
            <af:convertNumber groupingUsed="false" pattern="#{bindings.EmployeesView1.hints.EmployeeId.format}"/>
          </af:outputText>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.FirstName.label}" id="c2">
          <af:outputText value="#{row.FirstName}" shortDesc="#{bindings.EmployeesView1.hints.FirstName.tooltip}" id="ot2"/>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.LastName.label}" id="c3">
          <af:outputText value="#{row.LastName}" shortDesc="#{bindings.EmployeesView1.hints.LastName.tooltip}" id="ot3"/>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.Email.label}" id="c4">
          <af:outputText value="#{row.Email}" shortDesc="#{bindings.EmployeesView1.hints.Email.tooltip}" id="ot4"/>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.PhoneNumber.label}" id="c5">
          <af:outputText value="#{row.PhoneNumber}" shortDesc="#{bindings.EmployeesView1.hints.PhoneNumber.tooltip}"
                         id="ot5"/>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.HireDate.label}" id="c6">
          <af:outputText value="#{row.HireDate}" shortDesc="#{bindings.EmployeesView1.hints.HireDate.tooltip}" id="ot6">
            <af:convertDateTime pattern="#{bindings.EmployeesView1.hints.HireDate.format}"/>
          </af:outputText>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.JobId.label}" id="c7">
          <af:outputText value="#{row.JobId}" shortDesc="#{bindings.EmployeesView1.hints.JobId.tooltip}" id="ot7"/>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.Salary.label}" id="c8">
          <af:outputText value="#{row.Salary}" shortDesc="#{bindings.EmployeesView1.hints.Salary.tooltip}" id="ot8">
            <af:convertNumber groupingUsed="false" pattern="#{bindings.EmployeesView1.hints.Salary.format}"/>
          </af:outputText>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.CommissionPct.label}" id="c9">
          <af:outputText value="#{row.CommissionPct}" shortDesc="#{bindings.EmployeesView1.hints.CommissionPct.tooltip}"
                         id="ot9">
            <af:convertNumber groupingUsed="false" pattern="#{bindings.EmployeesView1.hints.CommissionPct.format}"/>
          </af:outputText>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.ManagerId.label}" id="c10">
          <af:outputText value="#{row.ManagerId}" shortDesc="#{bindings.EmployeesView1.hints.ManagerId.tooltip}" id="ot10">
            <af:convertNumber groupingUsed="false" pattern="#{bindings.EmployeesView1.hints.ManagerId.format}"/>
          </af:outputText>
        </af:column>
        <af:column headerText="#{bindings.EmployeesView1.hints.DepartmentId.label}" id="c11">
          <af:outputText value="#{row.DepartmentId}" shortDesc="#{bindings.EmployeesView1.hints.DepartmentId.tooltip}"
                         id="ot11">
            <af:convertNumber groupingUsed="false" pattern="#{bindings.EmployeesView1.hints.DepartmentId.format}"/>
          </af:outputText>
        </af:column>
      </af:table>
    </ui:composition>
    

    The complete error code is

    java.lang.NumberFormatException: null
      at java.lang.Long.parseLong(Long.java:404)
      at java.lang.Long.<init>(Long.java:702)
      at view.PrintReport1Servlet.doGet(PrintReport1Servlet.java:113)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
      Truncated. see log file for complete stacktrace
    > 
    <Mar 27, 2015 10:03:46 AM PKT> <Notice> <Diagnostics> <BEA-320068> <Watch "UncheckedException" in module "Module-FMWDFW" with severity "Notice" on server "DefaultServer" has triggered at Mar 27, 2015 10:03:46 AM PKT. Notification details: 
    WatchRuleType: Log 
    WatchRule: (SEVERITY = 'Error') AND ((MSGID = 'WL-101020') OR (MSGID = 'WL-101017') OR (MSGID = 'WL-000802') OR (MSGID = 'BEA-101020') OR (MSGID = 'BEA-101017') OR (MSGID = 'BEA-000802')) 
    WatchData: DATE = Mar 27, 2015 10:03:46 AM PKT SERVER = DefaultServer MESSAGE = [ServletContext@1295794488[app:JasperServletTester module:JasperServletTester-ViewController-context-root path:null spec-version:3.0]] Servlet failed with an Exception
    java.lang.NumberFormatException: null
      at java.lang.Long.parseLong(Long.java:404)
      at java.lang.Long.<init>(Long.java:702)
      at view.PrintReport1Servlet.doGet(PrintReport1Servlet.java:113)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:137)
      at java.security.AccessController.doPrivileged(Native Method)
      at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
      at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
      at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:120)
      at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:217)
      at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:81)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:220)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3436)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
      at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
      at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
     SUBSYSTEM = HTTP USERID = <WLS Kernel> SEVERITY = Error THREAD = [ACTIVE] ExecuteThread: '4' for queue: 'weblogic.kernel.Default (self-tuning)' MSGID = BEA-101020 MACHINE = TANVIR-PC TXID =  CONTEXTID = fd43f1ae-c573-4366-9924-18a1ab1a228f-0000008d TIMESTAMP = 1427432626062  
    WatchAlarmType: AutomaticReset 
    WatchAlarmResetPeriod: 30000 
    > 
    <oracle.dfw.impl.incident.DiagnosticsDataExtractorImpl> <DiagnosticsDataExtractorImpl> <createADRIncident> <incident 16 created with problem key "DFW-99998 [java.lang.NumberFormatException][oracle.security.jps.ee.http.JpsAbsFilter$1.run][JasperServletTester]"> 
    <oracle.adf.common> <AdfDiagnosticsJarsVersionDumpImpl> <executeDump> <Path of the jars version dump :C:\Users\TANVIR\AppData\Roaming\JDeveloper\system12.1.3.0.41.140521.1008\DefaultDomain\servers\DefaultServer\adr\diag\ofm\defaultdomain\defaultserver\incident\incdir_16/adf_DiagnosticsJarsVersionDump24_i16.txt> 
    

    For any help, I'll be very grateful

    Concerning

    Tender,

    As I mentioned in the other thread, the var0 comes null which causes this problem.

    Why var0 just null?

    You must change the property of destination as below:

    
    
    

    You must add "="

    See you soon

    AJ

  • Can a report of Jasper operate with an af:button on a page fragment (jsff) or simply on a jsf page?

    Mr President.

    Can a report of Jasper operate with an af:button on a page fragment (jsff) or simply on a jsf page?

    Because I'm running report jasper jsff page but it does not work but the same report runs on a jsf page.

    Concerning

    Cherish!

    The answer to this question is Yes

    We can run report jasper with a button on a page jsff using the servlet class

    The same code for jdev worm 12.1.3.0.0 is as below

    package ash.view;
    
    import ash.model.SchoolAppModuleImpl;
    
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    
    import java.util.HashMap;
    import java.util.Locale;
    import java.util.Map;
    
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.engine.xml.JRXmlLoader;
    
    import oracle.jbo.client.Configuration;
    
    @WebServlet(name = "ReportServlet", urlPatterns = { "/reportservlet" })
    public class ReportServlet extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=UTF-8";
    
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        }
    
        protected Connection getConnection() {
    
            PreparedStatement st = null;
            String amDef = "ash.model.SchoolAppModule";
            String config = "SchoolAppModuleLocal";
            SchoolAppModuleImpl am = (SchoolAppModuleImpl ) Configuration.createRootApplicationModule(amDef, config);
    
            st = am.getDBTransaction().createPreparedStatement("select 1 from dual", 0);
            Connection conn = null;    
    
            try {
                conn = st.getConnection();
                return conn;
            } catch (SQLException e) {
            }   
    
            return null;
        }
    
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            String var0 = "";
            try {
                var0 = request.getParameter("classId");
            } catch (Exception e) {
                e.printStackTrace();
            }
            response.setContentType(CONTENT_TYPE);
            Map parameters = new HashMap();
                   parameters.put("format", "pdf");
                   parameters.put("WEBDIR", getServletContext().getRealPath("/"));
                   parameters.put("REPORT_LOCALE", new Locale("ar"));
    
                   parameters.put("classId", new String(var0));
                   Connection conn = null;
                   InputStream is = null;
                   try
                   {
                     conn = getConnection();
                     is = getServletContext().getResourceAsStream("/WEB-INF/reports/ClassDataReport.jrxml");
    
                     response.setContentType("application/pdf");
                     response.addHeader("Content-Disposition", "attachment; filename=ClassDataReport.pdf");
    
                     JasperDesign jasperDesign = JRXmlLoader.load(is);
                     JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
                     JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
                     JasperExportManager.exportReportToPdfStream(jasperPrint, response.getOutputStream());
    
                     conn.close();
                   }
                   catch (Exception e) {
                     e.printStackTrace();
                   } finally {
                     closeConnection(conn);
                     try {
                         if(is !=null){
                             is.close();
                         }                   
    
                     } catch (Exception localException1)
                     {
                     }
                   }
    
            PrintWriter out = response.getWriter();
            out.println("");
            out.println("ReportServlet");
            out.println("");
            out.println("

    The servlet has received a GET. This is the reply.

    "); out.println(""); out.close(); } protected static void closeConnection(Connection conn) { try { if(conn !=null){ conn.close(); } } catch (Exception ex) { // System.out.println("Developer Msg : Exception in printReport1Servlet.closeConnection()"); } } }

    Concerning

  • Client application to consume the web service with security

    I need to write a simple client to access a WS.

    I can't do things

    1. Change the server
    2. Add external jars

    The customer will be part of a command line call and will work as a stand alone.

    I searched all day and have found hundreds of examples of wave, too complex, based mainly on SOAPHandler (who tells me that I need to install the server components that I can't do)

    I grasp the General requirements but finds it difficult to know how to add security features to the header.

    What should I do to add the chips of user name and password in the header?

    It is where I am so far.

    package findingLetter;
    
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    import javax.xml.namespace.QName;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPBodyElement;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.SOAPConnectionFactory;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPException;
    import javax.xml.soap.SOAPHeader;
    import javax.xml.soap.SOAPMessage;
    
    public class getPOC {
        public getPOC() {
            super();
        }
        public List<String> lookup(String lenderid, String url, String user, String pw) throws SOAPException {
            List<String> contactInfo = new ArrayList<String>();
            SOAPMessage message = MessageFactory.newInstance().createMessage();
            SOAPHeader header = message.getSOAPHeader();
            header.detachNode();
             
            SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
            envelope.setAttribute("namespace","http://www.siebel.com/xml/FHA%20Lender%20Summary%20Request%20IO");
             
            SOAPBody body = message.getSOAPBody();
            QName bodyName = new QName("LenderSummaryRequestIo");
            SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
            SOAPElement symbol = bodyElement.addChildElement("Institution");
            symbol.addTextNode(lenderid);
             
            SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();
            SOAPMessage response = connection.call(message, url);
            connection.close();
             
                    SOAPBody responseBody = response.getSOAPBody();
                    SOAPBodyElement responseElement = (SOAPBodyElement)responseBody.getChildElements().next();
                    SOAPElement returnElement = (SOAPElement)responseElement.getChildElements().next();
                    if(responseBody.getFault()!=null){
                        System.out.println(returnElement.getValue()+" "+responseBody.getFault().getFaultString());
                    } else {
                        System.out.println(returnElement.getValue());
                    }
             
                    try {
                        System.out.println(getXmlFromSOAPMessage(message));
                        System.out.println(getXmlFromSOAPMessage(response));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
            return contactInfo;
        }
        private static String getXmlFromSOAPMessage(SOAPMessage msg) throws SOAPException, IOException {
            ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
            msg.writeTo(byteArrayOS);
            return new String(byteArrayOS.toByteArray());
        }
    }
    

    Here's the code to add the security header.

    public List lookup (user string lenderid, String url, String, String pw) throws SOAPException {

    ............

    SOAPHeader header = message.getSOAPHeader ();

    If (header == null) {}

    Header = envelope.addHeader ();

    }

    SOAPElement headerElement = createSecurityHeader (uName, pWord);

    soapHeader.addChildElement (headerElement);...

    ........................

    }

    Private Shared { SOAPElement createSecurityHeader (uName, pWord String String) throws SOAPException

    SOAPElement UsernameToken = null;

    SOAPFactory SFactory = SOAPFactory.newInstance ();

    UsernameToken = sFactory.createElement ("wsse: UsernameToken", "", WS);

    SOAPElement Username = sFactory.createElement ("wsse:Username", "", WS);

    Username.setValue (uName);

    UsernameToken.addChildElement (Username);

    SOAPElement Password = sFactory.createElement("wsse:Password","",WS);

    Password.setValue (pWord);

    QName qname = new QName("","Type");

    Password.addAttribute (qname,"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText" ");

    UsernameToken.addChildElement (Password);

    SOAPElement wsseSecurity = sFactory.createElement("wsse:Security","",WS);

    wsseSecurity.addChildElement (UsernameToken);

    Return wsseSecurity;

    }

  • Jdev 12.1.3: Button that generates the pdf Jasper report does not return a user control

    Hi experts,

    I have a page jspx with a button that generates a PDF report of Jasper.

    My problem is that after pressing on and download the pdf file, the user cannot access other links more.

    If I put the mouse over the button is watch the mouse pointer as he was waiting for something.

    Therefore, the user must close the browser (I checked with Chrome, Firefox and IE) or refresh the page.

    This is the key:

    <af:button text="Print Project" id="ctb4"
                                                       actionListener="#{backingBeanScope.JasperBean.runReportPVT}"
                                                       partialSubmit="false"
                                                       icon="/images/icons/print_ena.png"/>
    

    And this is the code of the bean to support:

    public void executeReport() throws Exception {
      Connection conn = null;
      Date date = new java.util.Date();
      String timestamp = new Timestamp(date.getTime()).toString();
      try {
          HttpServletResponse response = getResponse();
          ServletOutputStream out = response.getOutputStream();
          response.setHeader("Cache-Control", "max-age=0");
    
    
          response.addHeader("Content-disposition", "attachment;filename=report_" + timestamp + ".pdf");
          
          response.setContentType("application/pdf");
          ServletContext context = getContext();
          InputStream fs =
              context.getResourceAsStream("/reports/template1.jasper"); 
          JasperReport template = (JasperReport) JRLoader.loadObject(fs);
          template.setWhenNoDataType(WhenNoDataTypeEnum.ALL_SECTIONS_NO_DETAIL);
          conn = getConnection();
          JasperPrint print = JasperFillManager.fillReport(template, paramMap, conn);
    
    
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          JasperExportManager.exportReportToPdfStream(print, baos);
          
          out.write(baos.toByteArray());
          out.flush();
          out.close();
          FacesContext.getCurrentInstance().responseComplete();
    
    
      } catch (Exception jex) {
          jex.printStackTrace();
      } finally {
          close(conn);
      }
    }
    

    If you do not need to view the report online, you can use af:fileDownloadActionListener

    Dario

Maybe you are looking for

  • MacBook Pro does not start safe mode or recovery mode without start up

    I use my MacBook Pro almost daily for several months now, and all of a sudden I stopped and start it up to a kernel panic (so it seems) who never lets me start normally, safe mode is a nothing helps. Recovery mode does not start, and when I try to us

  • Personal question Apple Modem

    I have a personal Modem from Apple (A9M0334) and have tried to connect it to my Macintosh Plus as well as my Apple / / e. The //e isn't any software of modem, but the Macintosh has MacTerminal 1.1. Telephone cables are connected to both ports on the

  • Microsoft Works

    I just bought a new computer without Microsoft Works (it has Wordpad instead) but I can ' t download a copy of the works from my old computer to my new computer (windows 8.1), which has all of my files and doc. on him. What can I do?

  • How my HP8620 come with one e-mail address? How can it be reversed and deleted

    I don't want an e-mail addreww for my printer how the ILO can be removed...

  • How to analyze an XML using C++ or Cascades

    Hello I'm developing a simple application of the Listview, this need for an updated list with the response from the server in XML, the XML as below: Gambardella, Matthew XML Developer's Guide Computer 44.95 2000-10-01 An in-depth look at creating app