You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Khalid Hajsaleh <kh...@chandleris.com> on 2005/01/30 04:50:25 UTC
jsp:useBean error
Hi,
I am trying to use the directive jsp:useBean in my jsp but that seems to
be causing an exception(at
org.apache.jasper.runtime.PageContextImpl.handlePageException), any
ideas?
Here is what I am trying to do:
In a forward.jsp, I have:
<%@ page import="Mylogin.UserLoginBean" %>
<jsp:useBean id="userLoginBean" scope="session" class="UserLoginBean" />
<jsp:setProperty name="userLoginBean" property="*"/>
My class Mylogin is defined in WEB-INF/classes/Mylogin/UserLoginBean. It
is suppose to validate a use login:
package Mylogin;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
public class UserLoginBean{
private String firstName;
private String lastName;
public UserLoginBean(){
}
public String getFirstName(){
return this.firstName;
}
public String getLastName(){
return this.lastName;
}
public void setFirstName(String firstName){
this.firstName=firstName;
}
public void setLastName(String lastName){
this.lastName=lastName;
}
public boolean isRegistered(){
try {
Context ctx = (Context)new
InitialContext().lookup("java:comp/env");
DataSource ds =
(DataSource)ctx.lookup("jdbcdb");
Connection conn = ds.getConnection();
if (conn != null)
System.out.println("CONNETED");
String stm="Select first_name from names where
item_id=?";
PreparedStatement selectStatement =
conn.prepareStatement(stm);
selectStatement.setString(1,firstName);
ResultSet rs = selectStatement.executeQuery();
if (rs.next())
{
setFirstName(rs.getString("first_name"));
conn.close();
return true;
}
else
{
conn.close();
return false;
}
} catch (Exception e) {
System.out.println("Got an exception! ");
System.out.println(e.getMessage());
return false;
}
}
}
Thanks for all the help in advance.
Khalid
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
jsp:setProperty
Posted by Khalid Hajsaleh <kh...@chandleris.com>.
I am trying to use the directive jsp:setProperty to set the attributes
on a bean. However, when I try to set a password field, I get the error:
Can't find a method to write property 'password' of type
'java.lang.String' in a bean of type 'Mylogin.UserLoginBean'
I am getting the password from the screen:
<p>text:
<input type="password" name="password">
and then in the jsp, I am calling
<jsp:useBean id="userLoginBean" scope="session"
class="Mylogin.UserLoginBean" />
<jsp:setProperty name="userLoginBean" property="password"/>
in the class, I have password:
String password;
public void setPassowrd(String password){
password=password;
System.out.println("inside password");
}
I am doing the same with other properties and it seems that password is
the only one running into problem.
Thanks for all the help in advance.
Khalid
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org