How to retrieve BASIC-auth username value when using JDBCRealm constraint?
I have a web application that uses a JDBCRealm security constraint configured as thus in my server.xml and web.xml for the context:
http://pastebin.ca/41635 (pastebin'ed to be brief)
After a user enters their BASIC credentials, how can I retrieve the username they logged in with?
For example, I have in mind something like this that I want to display in my JSP in the application:
Welcome back, <% out.print(request.getAuthUsername()); %>!
But there doesn't seem to be a ServletRequest method in the API to get this information.
Is this possible?
Answer:
<c:out value="${pageContext.request.remoteUser}"/>
Similar Messages
-
How To Retrieve an Object's Value Defined Using c:set ... Tag?
I have the value of a variable defined in JSP#1 (JSP#1 is not a form) using JSTL tag:
<c:set var="id" value="${articleForm.article}" scope="session"/>Now, I have an object 'id' in the session scope. The object 'id' and all the information, which are defined in JSP#1, are forwarded to JSP#2.
JSP#2 is a form. But, the 'id' is not used in JSP#2.
JSP#2 has a submit button and then, a servlet takes over the control after that button is clicked. All the text fields in JSP#2 together with the object 'id' are forwarded to this servlet.
I have two questions:
1. I should put this object 'id' in a request scope or a session scope? Currently, it is in a session scope.
2. How to retrieve the value of this object 'id' in this servlet? (I do not want to print the value out. I want to retrieve the value and store it in a database.)
int articleID = Integer.parseInt( session.getAttribute( "id" ) ); or, it should be retrieved in another way?I'm not sure you understand the concept of a session object.
Java objects stay on the server. There is no transmission between the web browser and the client.
The scope just sets how long the server "remembers" that variable.
request scope - only lasts one request. Once a web page is returned to the client, the server forgets all request variables.
session scope - lasts for one user - across multiple requests/web pages.
1. I should put this object 'id' in a request scope or a session scope? Currently, it is in a session scope.From your description, you appear to have it right - your object should be in session scope.
2. How to retrieve the value of this object 'id' in this servlet? (I do not want to print the value out. I want to retrieve the value and store it in a database.)If articleForm.article is an String then that looks the right way to access it.
You might have to do it like this:
int articleID = Integer.parseInt( (String)session.getAttribute("id"));
The Integer.parseInt method takes a String as a parameter - while session.getAttribute() returns an Object.
This code will work if the object stored in the session is a String.
The object stored in the session is ${articleForm.article} What type does articletForm.getArticle() return? That is the type you need to cast it to when retrieving it from the session.
Cheers,
evnafets -
How to assign permissions to choice values when using content types in a library
Hi,
I just now started using content types in document libraries instead of folder structure. The structure I was given is as follows:
Master group (library name)
L.A.
South Street
Number 1
Number 2
North Street
Number 1
Number 2
Boston
West Street
Number 1
Number 2
East street
Number 1
Number 2
India
North Street
Number 1
Number 2
West Street
Number 1
Number 2
So, I created a Content Type called Areas (which included LA, Boston, and India) and I created choice field values for each columns (South street and North street). Then, I gave the choice values as Number 1 and Number 2.
Now, the complexity was in terms of permission levels, wherein the client was accustomed to using folder structure. And hence, they had given a set to users to have access only to Number 1 of West street of Boston. Now that I have the content
type structure in place, how do I configure the granular permission for the 3rd level of the hierarchy?
Shonilchi..Thanks for your post. I had already done this via Windows Explorer, and it works for all of the My Docs files
but not Acrobat files, which still come up in List View. I am running Windows XP still, is that a factor? -
How do I display the correct value when using SELECT_LIST_FROM_QUERY
I have an updatable report that displays the possible values for a field.
I'm using HTMLDB_ITEM.SELECT_LIST_FROM_QUERY, so obviously I have to process the record manually.
However, I need the trick to display the correct value as selected before processing the records.
I appreciate your help.
Thanks
JuanThank you.
So, I just need to put the field name in the second argument.
I have it working now.
Thanks again
Juan -
How to retrieve a page item value in another page?
Hi,
how to retrieve a page item value in another page?
say P55_COURSES_TO_EVALUATE is my page item name and it is a select list.Based on the value selected,in the next page i shd show details related to the selected value and for this i need P55_COURSES_TO_EVALUATE value in the next page.How Do I get it?When I try to retrieve the values it simply returns nothing.
Any pointers would be really helpful.
Thanks in advance.Hi,
Could you please tell how you try use it ?
If you set value to item P55_COURSES_TO_EVALUATE and submit page, value is saved to session state.
Then you can use that item in any page like
:P55_COURSES_TO_EVALUATEYou can not access page value in javascript/jQuery from other pages like
$v('P55_COURSES_TO_EVALUATE')
document.getElementbyID('P55_COURSES_TO_EVALUATE')
$(#P55_COURSES_TO_EVALUATE)Because item is not in other pages. In javascript from other pages you can use
var a = '&P55_COURSES_TO_EVALUATE.';Regards,
Jari -
How to prevent basic auth dialog box?
Hi all,
I have a webservice protected with basic authtentication.
From my understanding I thought it would be possible to prompt the
user for a user name and password using a flex form and then do a
setCredentials on the WebService object to provide the server with
the needed info, thus avoiding the broswers dialog box.
However this does not work and I still get the browser dialog
box. Even worse if I log out of the flex application and try and
log in as a new user it seems the old credentials are cached by the
browser so the new user get security errors as the flex usernam and
basic auth username do not match up. This is how the app has been
coded.
Any idea?
thanksI'm sorry you're question is not clear to me. Please explain a bit further.
tanzim
If your query is resolved then please click on “Accept as Solution”
Click on the LIKE on the bottom right if the post deserves credit -
How to get a Tree Node Value when a Tree is Expanded
My reqiurement is when i Expand a Tree i need the Expanded tree Node Value. For Example Consider Parent as a Root Node of a Tree, and Consider its two Children Child1 and Child2.
When + Parent Expanded
I will Get the Output as --Parent
- Child1
- Child2
so As when i expand the Tree i must Get the String Value Parent.duplicate
How to get a Tree Node Value when a Tree is Expanded -
how to retrieve all datas that lost when i update my iphone4 to that 6.10 ios. i tried to look at may i tunes in my computer but it seems that i forgot to perform back ups since i purchased this phone 2yirs ago.. pls send me an advice..thank u.
All of the data should be on your computer, simply sync it back.
If the update was done via iTunes on the computer, the first step in the process is a backup of the device. -
How to retrieve data from domain(Value Range) of the table
hi
how to retrieve data from domain(Value Range) of the table
thanksHello,
You can try using the FM: DOMAIN_VALUE_GET TB_DOMAINVALUES_GET.
BR,
Suhas
Edited by: Suhas Saha on Mar 24, 2009 10:08 AM -
Prompting for password and username only when using dynamic parameters
Post Author: Co3023
CA Forum: Crystal Reports
How do I stop CR XI prompting for password and username only when using dynamic parameters. When no dynamic parameters are used CR XI isn't prompting for the DB user name and password. The report is run from an application which passes the user name and password. I am using Oracle and the problem is both with the native oracle driver and the ODBC RDO driver.Post Author: jehanzeb
CA Forum: Crystal Reports
I didnt ask you to change it to static I said I took the parameters totally out of the report. Saved it. Then re-enter the dynamic parameters into the report and it worked for me. That might have worked for you, not sure why you changed it to static.
Ok I have just created a quick report using dynamic parameters, it didnt ask me for the username password.
Can you create a sample report - just to test the db? and see if it works? add only 1 or 2 fields in the report, create parameters (dynamic) and see if it works
why don't you embed the username and password in your application, it won't ask for username password then. -
Keeping variable values when using an LMS
I have a program that uses variables for a branching, allowing me to mark what branch the student has completed. It works when you preview the course. When I publish to the LMS and take the course it works if I go straight through. But if I leave the course and then pick it up were I left off the variables that were set showing completion of the course no longer show the completion information. How can I maintain the variable values when the student exits the course?
Hi dmv@Morgan and welcome to the forums!
Here's what I've found to be true for my LMS:
If you set a default value for the variable in the variables panel, then the variable will be reset to that default value when the course resumes.
If you don't set a default value, then the LMS suspend data (aka resume data) will populate the variable with the previous value from the previous attempt.
Let us know how it goes,
Jim Leichliter -
How to transfer range parameter from vb when using bapi calling
Hi,everyone.how to transfer range parameter from vb when using BAPI calling?
Did you get the solution to your problem? Can you please share it with me. I have a similar problem. I have a VB program that calls RFC function. It works with a single parameter but not with a range of parameters. If you have the solution, could you please share sample codes with me? Thank you so much.
-
How can I show additional tab rows when using many open tabs?
How can I show additional tab rows when using many open tabs?
What method (code) did you use to get the Tab bar displaying in the space used for the Navigation Toolbar (location bar)?
The Tab bar should be displayed above the Navigation Toolbar.
Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
*Do NOT click the Reset button on the Safe Mode start window.
*https://support.mozilla.org/kb/Safe+Mode
*https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes -
I must purchase a photo editing tool and don't know if I should go with Photoshop or Lightroom. I need to learn how to do basic photo editing on pictures used for a news website. Thoughts? Thanks!
Hi scienceiscool,
You can go ahead with the photography plan as mentioned in the link below:
https://creative.adobe.com/plans/photography?promoid=KLXML
Kindly refer to the link below to get used to the application better:
Photoshop CC tutorials from novice to expert
Regards,
Sheena K -
How do images embeded in InDesign link when using Creative Cloud on more than two desktops?
How do images embeded in InDesign link when using Creative Cloud on more than two desktops?
If I am understanding your question correctly, you shouldn't have to worry about embedded images in InDesign. Once embedded, the image is stored within the file.
If you are wondering about linked images... InDesign will follow the path on your computer and, if it does not find the image, you will recieve a notification. Edit: To prevent this, I would suggest packaging your file using File > Package... This will create a folder with all of your fonts and linked graphics so that you need not worry about broken links. I just remembered that you cannot upload folders directly to Creative Cloud so a packaged folder wouldn't be very helpful unless you wanted to upload each file manually.
The best solution I see right now is to either embed the graphics in the document, or upload the images with your document to relink.
I hope this helped,
Michael
Maybe you are looking for
-
Issue with creating List of Values in Business View Manager
Hi, Could any one help me to figure out what this issue refers to? When i created a List of Values in Business View Manager, it is throwing the following error!!!! The List of Values used by this parameter cannot be based on a Business View derived f
-
How to install Java and Tomcat on my VPS
Hello, I am new in Java. I would like to install Java and Tomcat on my VPS server. Do you know which doc or info i should read? Thanks a lot. Gil
-
Apple ID. Am i stuck with a old email address forever?
Hi, i had a gmail email address for years which i used for everything, including itunes, so my account log on is [email protected] Since the @me and @icloud addresses were given out, i got one of these and the [email protected] is my primary used ema
-
Hi Java Gurus I am not able to compile this code Pl help class For { public static void main (String [] args) { int I = 0; show: if (I < 2) { System.out.print("I is " + I); I++; continue show; }
-
What is the reason of using ? extends anyobject in case of Interface.
My Question is this, why we use "extends" instead of "implements"