Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble in calling a bean twice

Amit Nair
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic