Search code examples
jasperserver

How to automatically load a report on home page after logged in Jasper Server Community


In Jasper Server Community Edition, I want to load a report automatically without clicking on any report when I logging. I tried to add below code to home.jsp page as jasperSoft documentation says.but it is not working.

Please help me with this.

Code that I added to home.jsp :-

<% 
<authz:authorize ifAllGranted="ROLE_REPORT_HOME"> 
<c:redirect
    url="http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2Freports&reportUnit=%2Freports%2FSample_Dash_Report&standAlone=true"/> 
</authz:authorize>
%>

Solution

    1. Go to Jasper server installation directory and search for jasperserver-servlet.xml (C:\Jaspersoft\jasperreports-server-cp-6.4.2\apache-tomcat\webapps\jasperserver\WEB-INF\jasperserver-servlet.xml)
    2. Under bean id = "homePageByRole" we have to make changes. For that, search homePageByRole word inside the jasperserver-servlet.xml file.
    3. Under tag ,we can give a report link we need according to the user roles. But make sure you should add amp; as after each & mark. Otherwise it will give an error!

      Example:-

      Original report link from the address bar in browser when report opened using jasper server is; http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2FMy_Reports&reportUnit=%2FMy_Reports%2FDashboard_Report_Landscape&standAlone=true

      But the link we should put under is; ROLE_USER|redirect:/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2FMy_Reports&reportUnit=%2FMy_Reports%2FDashboard_Report_Landscape&standAlone=true

      check how we add as amp; after every & mark. Also we can set user role. In my case I set user role as ROLE_USER.

    Whole code snippet is;

    <bean id="homePageByRole" class="java.util.ArrayList">
                <constructor-arg index="0" type="java.util.Collection">
                    <list>
                        <value>ROLE_ADMINISTRATOR|redirect:/flow.html?_flowId=searchFlow</value>
                        <value>ROLE_USER|redirect:/flow.html?_flowId=viewReportFlow&amp;_flowId=viewReportFlow&amp;ParentFolderUri=%2FMy_Reports&amp;reportUnit=%2FMy_Reports%2FDashboard_Report_Landscape&amp;standAlone=true</value>
                    </list>
                </constructor-arg>
    </bean>