Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
BIRT Sessions
Jac
Hi,
I am calling BIRT Report from my web application.I am using PHP in backend.I am passing the userId in a link.For example,assume i am logged in with userId=5 ,the report loads successfully.I manually replace userId=6 ,it again displays the report with userId = 6.This is not what i expect.I should check for the session and if userId = 5 it should load the report ,and if the userId=6 ,i should say an error message as 'U cant view the details'...Can u please let me know how to check for session in BIRT ?Please help me.
Thanks,
Jac
Find more posts tagged with
Comments
JasonW
Jac,
Do you mean the J2EE session object in the BIRT Viewer? If so you can get at it using
reportContext.getHttpServletRequest().getSession().getAttribute/setAttribute
Jason
Jac
Hi Jason,<br />
<br />
I donot use any java or j2ee objects.I am using PHP.I am passing the value in URL.I need to get the value from the URL and check it with SESSION.If SESSION matches i should allow the user to view the report ,else i have to give the user a message as 'You cannot view the report...'.Can you please help me to do this?<br />
<br />
<blockquote class='ipsBlockquote' data-author="JasonW"><p>Jac,<br />
<br />
Do you mean the J2EE session object in the BIRT Viewer? If so you can get at it using <br />
reportContext.getHttpServletRequest().getSession().getAttribute/setAttribute<br />
<br />
Jason</p></blockquote>
JasonW
I am not certain how to access PHP Session from BIRT. How do you have BIRT deployed? If you have it deployed on Tomcat you may be able to put some logic in the report to set the J2EE session to the value of the parameter and then if someone changes it forward to an error page.
Jac
Hi,<br />
<br />
I am using tomcat to deploy birt.I donot have any idea on J2EE sessions as you have mentioned.Can you please post sample code?It will help me a lot then.Looking forward from you.<br />
<br />
Thanks,Jac <br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="JasonW"><p>I am not certain how to access PHP Session from BIRT. How do you have BIRT deployed? If you have it deployed on Tomcat you may be able to put some logic in the report to set the J2EE session to the value of the parameter and then if someone changes it forward to an error page.</p></blockquote>
JasonW
You could do something like this in a report:
1 - in the beforeFactory put a script in with the following:
sessionMismatch = true;
var ses = reportContext.getHttpServletRequest().getSession().getAttribute("userid");
if( ses == null ){
reportContext.getHttpServletRequest().getSession().setAttribute("userid", params["tstparm"].value );
sessionMismatch = false;
}else{
if( params["tstparm"].value == ses ){
sessionMismatch = false;
}
reportContext.getDesignHandle().findElement("mytable").drop();
}
This will drop a table named mytable if the userid parameter does not match what has been put in the J2EE session. if this is the first time the report is ran for this particular session it will store the parameter as the userid in the J2EE session. The variable sessionMismatch is a global js variable because I did not use the keyword var. So I can use it in a text element at the top of the report to forward to a different web page.
The text element needs to be set to html and have the following expression:
<script>
function forward() {
location.replace("
http://www.google.com")
;
}
if( <VALUE-OF>sessionMismatch</VALUE-OF> ){
forward();
}
</script>
Jason