Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6857031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:57:51+00:00 2026-05-27T01:57:51+00:00

I wrote a simple JSF form. The problem is that there is a bug

  • 0

I wrote a simple JSF form. The problem is that there is a bug that I can’t find. When I open the main page and enter the username and password the page must redirect me to the next page but this is not happening. Can you help me to find my mistake?

This is the main login JSF page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:h="http://java.sun.com/jsf/html">
    <head>
        <title>Login</title>
        <link rel="stylesheet" type="text/css" href="resources/css/style.css" />
        <script src="resources/js/cufon-yui.js" type="text/javascript"></script>
        <script src="resources/js/ChunkFive_400.font.js" type="text/javascript"></script>
        <script type="text/javascript">
            Cufon.replace('h1',{ textShadow: '1px 1px #fff'});
            Cufon.replace('h2',{ textShadow: '1px 1px #fff'});
            Cufon.replace('h3',{ textShadow: '0px 1px #000'});
            Cufon.replace('.back');
        </script>
    </head>
    <body>
        <div class="wrapper">
            <div class="content">
                <div id="form_wrapper" class="form_wrapper">                    
                    <form class="login active">
                        <h3><center><img src="resources/images/title.png"/></center></h3>
                        <div>
                            <label>Username:</label>
                            <h:inputText value="#{loginController.user}"/>
                            <span class="error">This is an error</span>
                        </div>
                        <div>
                            <label>Password:</label>
                            <h:inputSecret value="#{loginController.password}"/>
                            <span class="error">This is an error</span>
                        </div>
                        <div class="bottom">    
                                                        <h:commandButton label="Login" value="Login" action="#{loginController.user_compare}"/>
                            <div class="clear"></div>
                        </div>
                    </form>                 
                </div>
            </div>          
        </div>  
    </body>
</html>

This is the managed bean

/** Bean for checking users and passwords.
 If the user enters the correct username and password 
 the user will be redirected to main.xhtml
 If not the page will refresh. */

package com.dx.sr_57;

import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;


@Named("loginController")
@SessionScoped
public class user_check implements Serializable {
    private String user;
    private String password;

       public user_check(){
       }

       public user_check(String user, String password){
           super();
           this.user = user;
           this.password = password;
       }



       /** get the content of the variables from the JSF Login page */

       public String setUser(String newValue) { 
           user = newValue; 
           return user;
       }

       public String getUser(){
           return user;       
       }

       public String setPassword(String newValue) { 
           password = newValue; 
           return password;
       } 

       public String getPassword(){
           return password;
       }

       public String user_compare() {        
            return "success";        
       }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:57:51+00:00Added an answer on May 27, 2026 at 1:57 am

    You need to use a <h:form> component in order to get JSF inputs and commands to work.

    So, replace

    <form class="login active">
        ...
    </form>
    

    by

    <h:form styleClass="login active">
        ...
    </h:form>
    

    You also need to fix your setters to be fullworthy setters, otherwise you might face a PropertyNotFoundException.

    So, replace

       public String setUser(String newValue) { 
           user = newValue; 
           return user;
       }
    
       public String setPassword(String newValue) { 
           password = newValue; 
           return password;
       } 
    

    by

       public void setUser(String newValue) { 
           user = newValue; 
       }
    
       public void setPassword(String newValue) { 
           password = newValue; 
       } 
    

    Unrelated to the concrete problem, the HTML <center> tag is deprecated since 1998 and invalid in XHTML strict. Remove it. You need to set CSS text-align: center on the <img> instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to render a simple link in a page that open a pdf
I wrote a simple collection class so that I can store my arrays in
I wrote simple silverlight web application using the default ASP test page. If there
I wrote simple load testing tool for testing performance of Java modules. One problem
I wrote a simple tool to generate a DBUnit XML dataset using queries that
I wrote a simple Sinatra app that generate an image using rmagick from some
I have a simple JSF+RichFaces form with some fields and obviously a backing bean
I wrote simple GUI page: public class Test01 { RootPanel r = RootPanel.get(); public
I wrote simple application that using the cell phone camera. When i trying to
I wrote simple update/insert statements that are returning a syntax error, what am I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.