Forums Register Login

Calling Java Bean from JSP

+Pie Number of slices to send: Send
I have registerform.jsp which asks for FirstName and LastName.The action passes to showData.jsp. I have a java bean class of setters and getters javabeans.CallingJavaBean
When I compile showData.jsp I get error message:

org.apache.jasper.JasperException: Cannot find a method to read property 'firstName' in a bean of type 'javabeans.CallingJavaBean'

can anyone help me???

register.jsp
************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registeration Form</title>
</head>
<body>
<form action="showData.jsp" method="Post">

<table align="center" border=0 >
<tr>
<th colspan="2"><h1>Registration Form </h1></th>
</tr>
<tr>
<td>
First Name:
</td>
<td>
<input type="text" name="firstName">
</td>
</tr>
<tr>
<td>
Last Name:
</td>
<td>
<input type="text" name="lastName">
</td>
</tr>
<tr>
<td align=center colspan=2>
<input type=submit value="REGISTER">
</td>
</tr>
</table>
</form>
</body>
</html>

showData.jsp
************

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>

<body>
<h1>JSP Page</h1>
<jsp:useBean id="callBean" class="javabeans.CallingJavaBean" />
<jsp:setProperty name="callBean" property="firstName" />
<jsp:setProperty name="callBean" property="lastName" />
<table>
<tr>
<td>
yuuuu
<jsp:getProperty name="callBean" property="firstName" />
<jsp:getProperty name="callBean" property="lastName" />
</td>
</tr>
</table>
</body>
</html>

CallingJavaBean
***************

package javabeans;


public class CallingJavaBean
{

private String firstName = null;
private String lastName = null;


public CallingJavaBean()
{

}
public String getFirsttName()
{
return firstName;
}

public String getLasttName()
{
return lastName;
}
public void setFirstName( String firstName )
{

this.firstName = firstName;
}


public void setLastName( String lastName )
{
this.lastName = lastName;
}

}
+Pie Number of slices to send: Send
 

Originally posted by Shanthi Mari:

public String getFirsttName()
{
return firstName;
}

public String getLasttName()
{
return lastName;
}



You could probably find what was wrong if you looked at your method name.
+Pie Number of slices to send: Send
Thanks.
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2006 times.
Similar Threads
error occuring while use jsp
jsp:getProperty name shows only first word in string.
How to invoke a method when back button in browser is clicked.
Getting error on calling method belongs to java class.
include directive doesn't work
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 10:14:26.