Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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.
reply
    Bookmark Topic Watch Topic
  • New Topic