• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Newbie Question!!! - Very simple jsp

I have a jsp page that will be deployed on Oracle AS.  I need to take the username of the person logged in and use that to call a report from the jsp page.  The following is the code that shows how the username is found from the App Server.  

<P>Hello <%= pReq.getUser().getName() %>.</P>   (this will display "Hello Intern")

I need to take that username and use it in a URL when someone presses a button.  i.e.

<user clicks button>
link to the following url

http://appserver:9999/reports/rwservlet?report=sales.rdf+p_username=Intern

Notice the username at the end of the URL.  I know this must be very simple, but please help me out.  I am new to jsp, I have done a couple of Java apps, so I know a <very> little.
0
Intern
Asked:
Intern
  • 5
  • 4
1 Solution
 
bloodredsunCommented:
<%=request.getParameter("p_username")%>
0
 
InternAuthor Commented:
can you please expand your answer a little bit.  I REALLY am a newbie.....

Could you just give me a little bit more code to show how you would grab that value when a button is clicked.  This is my very first portlet, and it will get me on my way.

Thanks for the quick response
0
 
bloodredsunCommented:
Can you be a bit more specific on what you want and I'll be happy to give you the code...
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
InternAuthor Commented:
I would like to have a button (for now that is all that needs to be displayed in the portlet), when the user presses sthe button they will be sent to the following URL:

http://appserver:9999/reports/rwservlet?report=sales.rdf+p_username=<username>

Where <username> is the username of the person signed into the portal.  The following code will actually display the correct username to the screen, I just need to get it in the url:

<P>Hello <%= pReq.getUser().getName() %>.</P>
0
 
bloodredsunCommented:
Do you mean like this?

<a href="http://appserver:9999/reports/rwservlet?report=sales.rdf+p_username=<%= pReq.getUser().getName() %>"><img src="button.gif"></a>
0
 
InternAuthor Commented:
That will probably work.  Let me test it out and get back to you.  You will definatly get the points.
0
 
bloodredsunCommented:
or

<form name="buttons">
<input name="button1" type="button" value="Go" onClick="javascript:document.location.href='http://appserver:9999/reports/rwservlet?report=sales.rdf+p_username=<%= pReq.getUser().getName() %>';"/>
</form>
0
 
bloodredsunCommented:
If it's in a jsp, you may need to call it as <%= request.getUserPrincipal().getName() %> if you are going to be using standard J2EE methods. I don't recognise getUser() as an HttpServletRequest method but maybe it's an Oracle AS object.
0
 
InternAuthor Commented:
I am sure that it is a Oracle AS object since I am using the default portlet that JDeveloper started with.  Anyway it worked great.  I will be posting another question very soon.  

I am going to need to figure out how to hide the Username in the URL or encode it and then decode it in the report.

Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now