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
Pretty cool :)
ReplyDeletehi, thanks !!
DeleteHi,
ReplyDeleteIm kinda new to jasper and this helped me alot..i used the additional parameter to remove decoration but how could i still make it possible to export pdf,csv and other format..would it be possible?
Great info! Thanks, this will help immensely in making the inclusion of Jasper Reports in our application appear seamless.
ReplyDeleteHi, thanks for the feedback and good luck with your integration!
DeleteHi ,I'm working with jasper server 5.6.1.I'm doing token authentication and it works.How can i call report using url by using token ?
ReplyDeleteHi,
ReplyDeleteI never used token based authentication with Jasper, but in this url :
https://community.jaspersoft.com/documentation/jasperreports-authentication-cookbook/v56/token-based-authentication
It is mentioned that the server looks for a principalParameter in the URL or the HTTP Request, have you tried passing your token as the value for that parameter?
Hi Ulises,
ReplyDeleteI would like to ask:
1. Is it possible to pass a dataSource to report through URL parameter?
2. How to pass a parameters for encoding and report's format (.pdf, xlsx, ..)?
tx a lot... :)
ReplyDeletethis article is very helpfull
Hi, thanks!
DeleteHi !
ReplyDeleteWhen I export as pdf, in IE it always shows file name "flow.pdf", Is there any parameter by which I can pass OUTPUT_FILE_NAME ?
Hi,
ReplyDeleteAs far as I know no, there is no way to accomplish this.
Outstanding!! This works! Thank you so much for taking the time to let others know how to do this. I've spent countless hours researching. This was exactly what I needed. Thank you!
ReplyDeleteHi,
ReplyDeleteIt's really a good method but I have a serious problem : I can access to jasperserver without authentification since this step is accomplished after accessing to my php application where I embeded jasperserver reports.
How can I solve this problem?
Could please help me?
Many thanks in advance
Best Regards
Hi, I'm not sure I understand your problem if you access jasperserver without authentication you should be able to embed your reports by adding at the end of your report url the parameter "&decorate=no" if you are using the community version or "&theme=embed&viewAsDashboardFrame=true" if using the enterprise version
Delete