Bonface4 0 Newbie Poster

Hi guys? I have been programming in Java using J2SE. currently am working on J2EE enterprise application development using JavaServer Faces Technology.Since am new to JavaServer Faces have decided to start by a simple login applications.Developing the interface is not a big problem but getting the parameters from the inputText and sending to my backing bean is my problem. When i try to login,the Server replies with an error javax.el.PropertyNotwritableException which i dont know how to handle.Please can someone explain to me whats wrong with my code.Below is my code for 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"
      >
    <h:head>
        <title>Welcome</title>
    </h:head>
    <body bgColor="blue">
        <center>  <p>Welcome our Customer(s).Please provide your username and password</p>
            <p> <h:graphicImage value="#{resource['log.png']}"/></p>
            <p><h:form>
                    <p><h:outputLabel for="user">
                    <h:outputText id="username" value="Username"/>
                </h:outputLabel>
                <h:inputText id="user" value="#{loginBean.setUserName('')}" required="true">
                </h:inputText></p><br/>

                <p><h:outputLabel for="pass">
                    <h:outputText id="password" value="Password"/>
                </h:outputLabel>
                <h:inputSecret id="pass" value="#{loginBean.setPassword('')}" required="true">
                </h:inputSecret><br/></p>

                <p> <h:commandButton id="submit" value="Login" action="success.xhtml"/></p>

            </h:form>
            </p>
        </center>

also code for Backing bean is as shown below.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package customers;

/**
 *
 * @author BoniLabs
 */
import java.sql.*;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class LoginBean
{
    //declarations
    Statement stm=null;
    ResultSet rset=null;
    PreparedStatement pstat=null;
    Connection con=null;
    String username=null;
    String password=null;
    boolean loop=false;
    public LoginBean()
    {

    }
    //connect and validate user
    public boolean validateUser()
    {
        try
        {
            String user;
            String pass;
            user=getUserName();
            pass=getPassword();
            Connections database=new Connections();
            con=database.getConection();
            do
            {
                loop=false;
                pstat=con.prepareStatement("SELECT * FROM users WHERE username=? AND password=?");
                pstat.setString(1, user);
                pstat.setString(2,pass);
                //
                rset=pstat.executeQuery();
                if(!rset.next()&&rset.getRow()==0)
                {
                 reload();
                }
                else
                {
                 success();
                }
            }while(loop);

        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        return false;
    }
    //method to set and get details
    public void setUserName(String user)
    {
        username=user;
    }
    public String  getUserName()
    {
        return username;
    }
    public void setPassword(String pass)
    {
        password=pass;
    }
    public String getPassword()
    {
        return password;
    }
    public String reload()
    {
      return "Login Failed.Try again";
    }
    public String success()
    {
     return "Logged.welcome you have been authorised";
    }

}
Thankyou.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.