wood burning stoves*
The moose likes Servlets and the fly likes Form Based secruity... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Form Based secruity..." Watch "Form Based secruity..." New topic
Author

Form Based secruity...

Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
I have implementet formAuthentication. I have basically used LDAP Authentication for this purpose. This seems to work fine. In my loginpage I use j_security:
<form method="POST" action="j_security">
<input type="text" name="j_username" />
<input type="text" name="j_username" />
</form>

Now the autentication part works perfectly fine. But now when I say request.getRemoteUser()... in the j_security servlet, I get null. Is there any thing else, that I need to do... I have been using Tomcat as the web server

thanks in advance
shashank


SCJP 1.4, SCWCD 1.4, SCBCD 1.5
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Do you really have two j_username input fields in your form ?


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

getRemoteUser returns null if the user has not been authenticated.
You're probably calling getRemoteUser before the user has actually been authenticated.
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
that was a typing mistake...its j_password.

But the user has successfully been authenticated. I have tried to search for this issue in other forums...No one has answer to this..but couple of people of have the same question...

thanks in advance...

shashank
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Which server are you using?
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
Tomcat!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

... version? More information please, for example are you using Apache as a front end?
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
Yes I am using Apache...
Kartik Lax
Greenhorn

Joined: Apr 23, 2006
Posts: 24
This worked for me, but only if authenticated will it return a value.

request.getUserPrincipal().getName();

-Hellkay
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by Shashank Tilwalli:
Now the autentication part works perfectly fine. But now when I say request.getRemoteUser()... in the j_security servlet, I get null. Is there any thing else, that I need to do... I have been using Tomcat as the web server


Um hang on, are you saying you have overridden or replaced the default j_security target?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form Based secruity...