• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling Java Bean from JSP

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}

}
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Shanthi Mari
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic