To give you some context recently while working on a new small project I needed to include a few Jasper Reports that where hosted in a Jasper Serverrepository. The main requirement was to include these reports in a lightweight application without the JAVA stack but using only HTML+JavaScript
To my knowledge there are 3 ways to accomplish this :
- Allow anonymous access to a given URL pattern (I had some troubles working with this approach)
- Use Jasper's REST APIand authenticate through it (probably the cleaner way)
- Provide credentials in the URL (quick and dirty) :)
For reasons outside the scope of this article I had to use the 3rd option and provide the credentials in the URL.
Jasper server uses spring under the hood to provide authentication/authorization so you can use the standard Java authentication mechanism, which basically consists in providing the following parameters in the URL :
- j_username
- j_password
- j_acegi_security_check (this one is optional depending on the Jasper Server version)
If your Jasper Server is configured using an organization you will need to provide it as long with your credentials using the special syntax j_username=myUsername|myOrganization
So for example if the base url for your report is the following :
http://my-jasperserver/flow.html?_flowId=viewReportFlow&standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Freports%2Fsamples&reportUnit=%2Freports%2Fsamples%2FStandardChartsEyeCandyReportAnd your credentials are :
- username : jasperadmin
- organization : myOrg
- password: jasperadmin
Your URL will become :
http://my-jasperserver/flow.html?_flowId=viewReportFlow&standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Freports%2Fsamples&reportUnit=%2Freports%2Fsamples%2FStandardChartsEyeCandyReport&j_acegi_security_check&j_username=jasperadmin|myOrg&j_password=jasperadminOne last thing.By default when showing a report you will get all of Jasper Server decoration around it (menubars, links, etc.) you can get rid of this by appending the one of following parameters to the URL (please note that parameters are not the same depending on which version of Jasper you are using : Community or Corporate)
- Remove jasper decoration in community version : &decorate=no
- Remove jasper decoration in corporate version : &theme=embed&viewAsDashboardFrame=true