File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Trouble in calling a bean twice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Trouble in calling a bean twice" Watch "Trouble in calling a bean twice" New topic

Trouble in calling a bean twice

Amit Nair

Joined: May 23, 2006
Posts: 16
Hi Team

I am having trouble in creating a correct way to login in my application. The problem is, if the user gives correct authentication in the first attempt then he is forwarded to the next page, on failure the same login page is shown. Now second time if the user gives correct username/password, the login doesn�t happen. Even the bean method is not called after the user hits submit.

The Login page is a simple JSP with two text field for user name & password .

<h:inputText id="userNameInput" value="#{authenticateAction.user.userName}" size="30" rendered="true" />

<h:inputSecret value="#{authenticateAction.user.password}" size="30" rendered="true" required="true" redisplay="false" id="password"/>

<h:commandLink id="login" action="#{authenticateAction.authenticate}">
<h:graphicImage id="loginGif" url="/images/trns_login_btn.gif" styleClass="greenbt" style="border-color: transparent; border-width: 0" />

Code of bean
public class AuthenticateAction
private User user;

public AuthenticateAction() {
user = new User();
public String authenticate() {
// Code for authentication is done which return a User object

if (user != null) {
Map<String, User> sessionMap = context.getExternalContext().getSessionMap();
sessionMap.put("userLoggedIn", user);

return �SUCCESS�;
return �FAILURE�;
public User getUser() {
return user;

public void setUser(User user) {
this.user = user;

In the faces-config.xml the navigation for Login page is defined, �SUCCESS� takes the user to the next page & failure takes him back to the same page.

Please let me have your valuable input.

Thanks in advance

I agree. Here's the link:
subject: Trouble in calling a bean twice
It's not a secret anymore!