Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve Username in a .jsp page

SOLVED
Go to solution
Highlighted
Kalin Petrov
Super Collector

Retrieve Username in a .jsp page

Hi All,

I'm trying to incorporate a link into a request. The link has to point to an external system and must be generated dynamically, because it's going to carry information for the user who has pressed it - for instance username, is the user a PM, and so on...
My approach is to create a new .jsp page. Hardcode a link to it. And in that page's logic to compute the user specific parameters, dynamically build the link and then redirect the user to the 3rd party system.

I'm currently stuck into the .jsp page logic - can anybody tell me how in the .jsp page I can get the username of the user who is currently logged into the system (the one who opens the page)?

Thanks in Advance,

Kalin Petrov
8 REPLIES
Sascha Mohr
Esteemed Contributor
Solution

Re: Retrieve Username in a .jsp page

Hi.
Would it be an option, to create a custom data source and portlet definition in PPM containing that link? This way you could use standard tokens to include the information you mentioned in the URL of the link.
Regards
Sascha
Kalin Petrov
Super Collector

Re: Retrieve Username in a .jsp page

Thanks, Sasha, that's a good idea!
But unfortunatelly in our case we need to show this link among the request details, where portlet can not be used.

Thanks & Regards,

Kalin Petrov
Kalin Petrov
Super Collector

Re: Retrieve Username in a .jsp page

Sascha, sorry for misspelling your name in my post above :(
Sascha Mohr
Esteemed Contributor

Re: Retrieve Username in a .jsp page

No prob, if you are populating a field in your request with a request rule, you can use tokens there as well (like [SYS.USER_ID]).
Regards
Sascha
Kalin Petrov
Super Collector

Re: Retrieve Username in a .jsp page

Hi Sascha,

Yes, but the data populated in the request field will be populated for a definite user, and then the request might be opened by another user who should be able to click the link and be redirected using data specific for his user.
For instance, if the rule is "on create" the hidden filed will be populated with the username of the one who created the request. But later on if the request is opened by a PM for instance, clicking on the link would result in using the "username" of the user who created the request, instead of the PM's username.

Thanks & Regards,

Kalin Petrov
Sascha Mohr
Esteemed Contributor

Re: Retrieve Username in a .jsp page

True, in that case you will need the custom portlet, as it calculates its content "on demand".
I know of a solution to call an external SW with a report that points to a JSP with something like this in it:

<%-- set used parameters to request scope, so that they can be accessed in java --%>



For this you need a report with the appropriate report parameters of course.
Maybe not the right thing in your situation.
Regards
Sascha
Kalin Petrov
Super Collector

Re: Retrieve Username in a .jsp page

Hi Sascha,

yes, this is also what I was planning to do, but instead of passing through the report, in order to generate the jsp. I was planning to write the .jsp page with the incorporated logic, and provide a static link from the request to it.
The trouble is that I don't have much jsp experience and I'm not sure how to retrieve the username of the logged user in the jsp page.

In your example:



with what shall I replace "${USER_ID}" in order the variable "userID" to be assigned with the current user name?

Thanks & Regards,

Kalin Petrov
Sascha Mohr
Esteemed Contributor

Re: Retrieve Username in a .jsp page

That will be the difficult point, the report definition passes the value as ${USER_ID} to the JSP. The logic happens in the report here. The JSP is called from the report like this:

ksc_run_jsp_report /web/knta/rpt/jasper/mycustomreport.jsp
REPORT_ID=[RP.REPORT_SUBMISSION_ID]
USER_ID=[RP.CREATED_BY]
ksc_end_report_parameters

That's where ${USER_ID} gets its value.
So, you will probably need someone fit in creating JSPs (frankly, I'm not) who knows how to pass parameters through the URL (like on this page: http://forums11.itrc.hp.com/service/forums/postanswer.do?threadid=1286069&forumId=1&closedFlag=0) and how to work with taht in the JSP.
Regards
Sascha
//Add this to "OnDomLoad" event