?
Solved

Newbie Question!!! - Very simple jsp

Posted on 2005-04-26
9
Medium Priority
?
274 Views
Last Modified: 2011-10-03
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
Comment
Question by:Intern
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13868182
<%=request.getParameter("p_username")%>
0
 
LVL 1

Author Comment

by:Intern
ID: 13868198
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
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13868204
Can you be a bit more specific on what you want and I'll be happy to give you the code...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:Intern
ID: 13868235
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
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13868238
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
 
LVL 1

Author Comment

by:Intern
ID: 13868246
That will probably work.  Let me test it out and get back to you.  You will definatly get the points.
0
 
LVL 29

Accepted Solution

by:
bloodredsun earned 2000 total points
ID: 13868261
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
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13868339
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
 
LVL 1

Author Comment

by:Intern
ID: 13868479
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Social messanging services like WhatsApp and Facebook can help businesses in ways that many owners don't even imagine, giving new opportunities to connect with customers. Discover some of the most innovative things they can do for your company.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question