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 7943207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:12:06+00:00 2026-06-04T00:12:06+00:00

I am not able to get username and password values that I am entering

  • 0

I am not able to get username and password values that I am entering on the xhtml page in my ManagedBean.

This is why i am getting NullPointerException in goodBye method when I am checking username and password

Login.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui" xmlns:lang="en">
<f:view>
    <head>
<title>Test Client Login</title>
    </head>
    <h:form id="loginForm">
        <table align="center" border="1" style="padding-top: 100px">
            <tr>
                <td><h:outputLabel for="username2">
                        <h:outputText id="usernameLabel" value="Enter Username:" />
                    </h:outputLabel>
                </td>
                <td><h:inputText id="username" value="#{loginBean.username}"
                        required="true">
                        <f:validateLongRange minimum="1" maximum="500" />
                    </h:inputText>
                </td>
            </tr>
            <tr>
            <td>
                <h:outputLabel for="password2">
                    <h:outputText id="passwordLabel" value="Enter Password:" />
                </h:outputLabel></td>
                <td><h:inputText id="password" value="#{loginBean.password}"
                    required="true">
                    <f:validateLongRange minimum="1" maximum="500" />
                </h:inputText></td>
            </tr>
            <tr>
            <td colspan="2">
                <h:commandButton id="goodbyeCommand" type="submit" value="submit"
                    action="#{loginBean.goodbye}" immediate="true" />
            </td>
            </tr>
        </table>
    </h:form>
</f:view>


</html>

LoginBean.java

package com.example.ws.ui;

import org.apache.log4j.Logger;

/**
 * Managed Bean for Login
 * 
 */
public class LoginBean { 

    private static final Logger logger = Logger.getLogger(LoginBean.class); 


    //EbzWS userManager;

    private String username;
    private String password;  
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String goodbye() {
    /*  try {

            userManager.getEbzById("asdad", "asdad");
            logger.info("method called");
        } catch (ServiceException e) {
            System.out.println(e);
        }*/
        String dest = "failure";
        if(username.equals("sunny") && password.equals("sunny")){
            dest = "success";
        }
        return dest;
    }
    /*public EbzWS getUserManager() {
        return userManager;
    }
    public void setUserManager(EbzWS userManager) {
        this.userManager = userManager;
    }*/

}

faces-config.xml

<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
      http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    version="1.2">
    <managed-bean>
        <description>Login Bean</description>
        <managed-bean-name>loginBean</managed-bean-name>
        <managed-bean-class>com.example.ws.ui.LoginBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <description>EBZ Bean</description>
        <managed-bean-name>getEbzByIdBean</managed-bean-name>
        <managed-bean-class>com.example.ws.ui.GetEbzByIdBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <managed-bean>
        <description>WsListing Bean</description>
        <managed-bean-name>wsListingBean</managed-bean-name>
        <managed-bean-class>com.example.ws.ui.WsListingBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/login.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/wsListing.xhtml</to-view-id>
            <redirect />
        </navigation-case>
        <navigation-case>
            <from-outcome>failure</from-outcome>
            <to-view-id>/failure.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/wsListing.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>ebzService</from-outcome>
            <to-view-id>/ebzinput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
        <navigation-case>
            <from-outcome>filterEbz</from-outcome>
            <to-view-id>/filterebzinput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>


    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/ebzinput.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/ebzoutput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>
    <application>
        <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>en</supported-locale>
            <supported-locale>es</supported-locale>
        </locale-config>
        <message-bundle>messages</message-bundle>
    </application>
</faces-config>
  • 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-06-04T00:12:08+00:00Added an answer on June 4, 2026 at 12:12 am

    The immediate="true" on your command button causes JSF to skip all lifecycle phases until INVOKE APPLICATION. So your values are not set. Remove this attribute and it should work as expected.

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

Sidebar

Related Questions

not able to get this, can someone help for this LINQ query? select col1,
I'm not able to get this persistence file correct... I do not find any
i tried to search this but was not able to get any proper help.I
This seems like a repeated question but i'm not able to get my answer.
I know this is simple but I am not able to get it right
I'm able to recieve the requested xml with curl -X GET -u username:password url
I am not able to get the hg head or status for a given
I am not able to get my jwysiwyg and Jhtmlarea text editors to work
I've read the DateFormatting guide and I'm still not able to get a working
I have few Question for which I am not able to get a proper

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.