Get the value in session for report

  • Last update:May 08, 2021
  • I. Description

    Session saves the key-value attribute, and I hope to get the value of the key in the session in the report.

    II. Situation one

    Get the value in the Session directly in the template.


    1. Idea

    The report application is integrated into the user system and shares the same session. At this time, the value of the session can be directly obtained in the report.

    If key a is saved in the session and its value is 123, then use =$a in our report to directly get the value of a in the session.

    III. Situation two

    In the web page, the value in the Session is first obtained and then passed to the report in the iframe.


    1. Idea

    Taking JSP as an example, the value of key in the Session can be obtained through session.getAttribute(String key) and grafted into the src of the report iframe embedded in the JSP.


    2. Example

    In the user system, through session.setAttribute(String key,Object value); saves information in the Session such as fine_username=Anna,

    Get fine_username through session.getAttribute("fine_username") in JSP, and then pass it to the report. The code example is as follows:

    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <html> <body> <iframe width=100% height=100% src='/webroot/decision/view/report?viewlet=getkey.cpt&country=<%=session.getAttribute("fine_username")%>'> </iframe> </body> </html>

    The fine_username value can be obtained in the report template, as shown in the following figure:

    The effect is as follows:

    1534902674POFmsbPI.png

    Note: JSP files can only be parsed by the server.

    IV. Situation three: Get Session in JS

    Normal cpt template, JS get Session method:

    contentPane.currentSessionID

    Note: If the FineReport  is embedded in the iframe of the HTML page, then the Session can be obtained through document.getElementById('reportFrame').contentWindow.contentPane.currentSessionID

    frm template, the method for JS to obtain Session is:

    _g().sessionID



    Attachment List


    Theme: Report Features
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy