Home
Analytics
retrieve username from session in dataset
Arif shah
<p>Hi,</p><p> </p><p>In my dataset, I would liek to have a query like</p><p> </p><p>select * from students</p><p>where username = ?session_user?</p><p> </p><p>Can someone please help me how can I retrieve the user from session into this query</p><p> </p><p>Regards</p><p>Arif</p>
Find more posts tagged with
Comments
GLO_FR
<p>Hi,</p><p> </p><p>what kind of verison of BIRT are you using ?</p><p> </p><p>If it's Eclipse BIRT (=BIRT OpenSource), you can simply use a parameter.</p><p> </p><p>Create a new report parameter and when you call the report from your java class/URL or whatever, just pass the session_user name.</p><p>Use this new information inside your query, report like a normal parameter</p>
Arif shah
<p>Hi,</p><p> </p><p>Many thanks for the reply. I have one more question. Is it possible to pass the parameter as a hidden value so that the user does not see the long list of parameters (If I am passing multiple parameters)?</p><p> </p><p>Regards</p><p>Syed</p>
GLO_FR
<p>With a simple URL ? Not really.</p><p> </p><p>Probably with session variable (I have to check)</p>
GLO_FR
<p>Hi,</p><p> </p><p>yes it's possible with session variable.</p><p>Just set "<strong>yoursessionvar</strong>" in in your web page and, in the report, create a parameter and set the default value to</p><pre class="_prettyXprint">reportContext.getHttpServletRequest().getSession().getAttribute("yoursessionvar");</pre><p>and that's it.</p>
Arif shah
<p>Hi,</p><p> </p><p>I am sorry I am a bit unclear about this area and I really appreciate the help that you are providing. Can you please explain in which webpage can we set the <strong><span>yoursessionvar</span></strong> and what is the syntax going to be for this?</p><p> </p><p>One again, many thanks for your time and help</p><p> </p><p>Regards</p><p>Arif</p>
Arif shah
<p>I have not embedded/integrated the Birtviewer into any application and I am using it as a standalone app. I have used tomcat form based authentication to secure the report. How would I set the session variable in this case?</p><p> </p><p>Arif</p>
GLO_FR
<p>Hi again</p><p> </p><p>Here is a compete example (jsp+design)</p><p> </p><p>Deploy the 2 jsp files on your TOMCAT</p><p>Deploy the 2 rptdesign in the TOMCAT ressource folder <span style="font-size:14px;">(maybe change a little bit the </span><span style="font-size:14px;">session_child.</span><span style="font-size:14px;">jsp to have the correct path)</span></p><p> </p><p>connect to to the session_main.jsp page, and follow the link</p>
Arif shah
<p>Many thanks for the help. I have now started to grab the idea how it works. In my case, I have created a login form that accepts username and password and in action I have used <strong>j_security_check</strong>, Its a very simple user login form. My question is whether its possible to update j_security_check action so that after the security is checked, it sets the parameter before running the report</p><pre class="_prettyXprint"><form method="POST" action="j_security_check"><table> <tr> <td colspan="2">Login to the Tomcat-Demo application:</td> </tr> <tr> <td>Name:</td> <td><input type="text" name="j_username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="j_password"/ ></td> </tr> <tr> <td colspan="2"><input type="submit" value="Go" /></td> </tr></table></form></pre><p>I somehow would like the j_security_check to run below before executing the report</p><pre class="_prettyXprint"><% session.setAttribute("myName",request.getParameter("user"));%></pre><p>Regards</p><p>Arif</p>
GLO_FR
<p>Do you call the report with java or create a redirection to an URL?</p>