Skip to main content

Please help - JSF newbie question on user authentication

1 reply [Last post]
savoym
Offline
Joined: 2006-08-22

I am working on an online tutorial where in my POJO I am trying to acquire the userID value to display on my webpage. I am working in Eclipse and I put a breakpoint in my bean but I never get there. Here is the code I'm using and any help/direction would be greatly appreciated:

<br />
package org.texashealth.transfer.user;</p>
<p>import javax.servlet.http.HttpServletRequest;<br />
import javax.faces.bean.*;</p>
<p>@ManagedBean<br />
public class User {</p>
<p>	private String userID;</p>
<p>	public String getUserID() {<br />
		return userID;<br />
	}</p>
<p>	public void setUserID(String userID) {<br />
		this.userID = userID;<br />
	}</p>
<p>	public String authenticate(HttpServletRequest request) {<br />
		userID = request.getRemoteUser().substring(6);<br />
		return userID;<br />
	}<br />
}<br />

In the JSP page I have the following:

</p>
<p>JSF Test Form</p>
<p>  Here is the userID: <br />
  Some random data:<br />
  Some other data:    ]</p>
<p>

I also tried modifying my getUserID method above to use a FacesContext method but still got a NULL value:

<br />
public String getUserID() {<br />
userID = FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();<br />
return userID;<br />

Forgot to add additional code change made for other's info.

Message was edited by: savoym

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
savoym
Offline
Joined: 2006-08-22

I resolved my problem.