I am new to Java... I made this application, but the problem is that when I run the project I am getting the text which i have written in h
tag's value
attribute instead of the value from the bean. I have searched a lot but the problem is still there. The code and the screenshot tells the rest of the story. Here is my login.jsp:
</head>
<body>
<f:view>
<div class="login_container">
<h:messages errorClass="errorMsg"/>
<div class="login_box">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div class="login_wrap">
<div class="login_logo">
<img src="images/login_logo.gif" width="116" height="141" />
</div>
<h:form id="login_form">
<div class="login_form">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="float: left;">
<h2 class="orange">
Please Login
</h2>
</div>
<div class="login_icon">
<img src="images/icn_lock.png" width="16" height="16" />
</div>
</td>
</tr>
<tr>
<td>
<label>
Username
</label>
</td>
</tr>
<tr>
<td><h:inputText id="username" value="#{loginBean.username}" /></td>
</tr>
<tr>
<td>
<label>
Password
</label>
</td>
</tr>
<tr>
<td><h:inputText id="password" value="#{loginBean.password}"/>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td align="left" valign="middle">
<h:commandButton image="images/btn_login.gif" id="loginButton" action="#{loginBean.login}"
style="width:81px; height:29px" />
</td>
</tr>
</table>
</div>
</h:form>
</div>
</td>
</tr>
<tr>
<td>
<div class="login_box_bt">
</div>
</td>
</tr>
</table>
</div>
<div class="login_footer_box">
<div class="login_footer">
<div class="login_footer_text">
<p>
<span class="text_orange">Phone:</span> (+92-51) 5120684
<br />
<span class="text_orange">E-mail:</span> support@noeticworld.com
<br />
<span class="text_orange">Web:</span> http://www.noeticworld.com.pk
</p></div>
<div class="login_footer1_text">
<p>
<span class="text_orange">Leading VAS Solution Provider
</span>
<% /**<span class="text_orange">Fax:</span> (+92-51) 260 9263*/ %>
<br />
</p></div>
</div>
</div>
<div class="login_box_bt">
</div>
</f:view>
</body>
</html>
here is my backingbeans :
public class LoginBackingBean
{
private String username;
private String password;
private Boolean rememberMe;
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 Boolean getRememberMe()
{
return rememberMe;
}
public void setRememberMe(Boolean rememberMe)
{
this.rememberMe = rememberMe;
}
public String login()
{
boolean isValidUser = true;
String message = "";
Employee employee = null;
try
{
employee = getCurrentEmployee();
if (employee == null)
{
isValidUser = false;
message = "Sorry, the username or password is incorrect. Please try again";
}
}
catch (SQLException e)
{
isValidUser = false;
message = e.getMessage();
e.printStackTrace();
}
if (!isValidUser)
{
FacesMessage facesMessage = new FacesMessage();
facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR);
facesMessage.setSummary(message);
FacesContext.getCurrentInstance().addMessage("login_form", facesMessage);
return "failure";
}
EmployeeBackingBean employeeBackingBean = EmployeeBackingBean.getEmployeeBackingBean(employee);
List<Integer> recursiveSubordinatesIds;
try
{
recursiveSubordinatesIds = new EmployeeDAOImpl(DigiDeskDAO.getSqlMapper()).selectIdsOfRecursiveSubordinates(employeeBackingBean.getEmployeeId());
employeeBackingBean.setRecursiveSubordinatesIds(recursiveSubordinatesIds);
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
SessionManager.setEmployeeInSession(employeeBackingBean);
return "success";
}
/**
* This function finds the employee with the provided username and password
*
* @return - Employee object if validation succeeds, null if no matching user is found
* @throws SQLException
*/
private Employee getCurrentEmployee() throws SQLException
{
EmployeeDAOImpl employeeDAOImpl = new EmployeeDAOImpl(DigiDeskDAO.getSqlMapper());
EmployeeExample employeeExample = new EmployeeExample();
EmployeeExample.Criteria criteria = employeeExample.createCriteria();
criteria.andUsernameEqualTo(username);
criteria.andPasswordEqualTo(password);
List<Employee> employeesList = employeeDAOImpl.selectByExampleWithBLOBs(employeeExample);
if (employeesList.isEmpty())
{
return null;
}
Employee employee = employeesList.get(0);
return employee;
}
}
This is the problem, username and password shows the text: