UserInfoBean.java is the corresponding java managed bean file for index.xhtml

UserInfoBean.java is the corresponding java managed bean file for index.xhtml

 am doing a project in java ee. I use xhtml and managed bean for the web application interface.I want to check whether the email id value which the user enters in the login page comes to the next corresponding page. How do I do that?

I have attached the files. index.xhtml is the login page where user gives the input, reserve is the page where the user gets to see after loggin in. UserInfoBean.java is the corresponding java managed bean file for index.xhtml.

Would really appreciate some help on this.

I couldnt attach the xhtml file. Pasting it here.
index.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">  
 <f:view>  
    <h:head>  
        <title>Car Rental Application </title>  
    </h:head>  
    <h:body>  
        <h:form>  
            <h1><center>Car Rental Application</center></h1>  
            <h3> Login with your Email Id. </h3>  
            <table>  
                <tr>  
                    <td> User Id[Email]</td>  
                    <td>  
                        <h:inputText value="#{userInfoBean.email}" required="true"/>  
                    </td>  
                </tr>  
                <tr>  
                    <td> Password</td>  
                    <td>  
                        <h:inputSecret value="#{userInfoBean.password}" required="true"/>  
                    </td>  
                </tr>  
            </table>  
            <p>  
                <h:commandButton value="Login" action="#{userInfoBean.validateInput}"/>  
            </p>  
        </h:form>  
 
    </h:body>  
</f:view>  
</html> 
<?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">
 <f:view>
    <h:head>
        <title>Car Rental Application </title>
    </h:head>
    <h:body>
        <h:form>
            <h1><center>Car Rental Application</center></h1>
            <h3> Login with your Email Id. </h3>
            <table>
                <tr>
                    <td> User Id[Email]</td>
                    <td>
                        <h:inputText value="#{userInfoBean.email}" required="true"/>
                    </td>
                </tr>
                <tr>
                    <td> Password</td>
                    <td>
                        <h:inputSecret value="#{userInfoBean.password}" required="true"/>
                    </td>
                </tr>
            </table>
            <p>
                <h:commandButton value="Login" action="#{userInfoBean.validateInput}"/>
            </p>
        </h:form>

    </h:body>
</f:view>
</html>
 
 
import javax.faces.bean.ManagedBean;  
import javax.faces.bean.SessionScoped;  
//import javax.faces.bean.RequestScoped;  
import java.io.Serializable;  
 
 
@ManagedBean(name="userInfoBean")  
@SessionScoped 
public class userInfoBean implements Serializable{  
    private String email;  
    private String password;  
 
    
     
    public String getPassword(){  
        return password;  
    }  
    public void setPassword(String password){  
        this.password = password;  
    }  
 
    public String getEmail(){  
        return email;  
    }  
    public void setEmail(String email){  
        this.email = email;  
    }  
 
 
    public String validateInput(){  
         
            return "reserve.xhtml";  
        }  
      
        } 
on the previous post, in jsp there is getParameter,setAttribute and getAttribute. what I need is achieved through this. any idea how to do it in jsf?

I see you found the "code" button but didn't know how to work it properly, so I fixed your post so I could read it. To use the code button, highlight the code (or data) text and then click the "Code" button. Attachments are not necessary for code or XML.

JSF is really about manipulating beans, not working with pages. Pages are just the View in JSF's MVC architecture. SO when you fill in a JSF form and fire off an action, JSF will validate the input, and if the input is valid, it will automatically invoke the "set" methods for the form's properties. Then it will invoke your action method which can do whatever it needs to do with the assurance that the bean's properties were updated from the form inputs and that the properties are valid according to the validation restrictions placed on the form.

Other than that, all I can say is don't use user-written login screens in production apps. They're insecure.

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright