Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Plz help..how to make a bean class

 
rejieve alexander
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm kind of new to jsp,My formTest.jsp code is as below
<html>
.....
<input type = "text" name"firstName">
<input type = "text" name"lastName">
............
<% if (request.getMethod.equals("Post") { %>
<jsp:useBean id="formHandler" scope="application" class="com.rejieve.Formbean">
<jsp:setProperty name="formHandler" property="firstName"/>
</jsp:useBean>
You have entered :
<jsp:getProperty name="formHandler" property="firstName"/>
<%
}
%>
now could someone help me as to,how do i declare the bean properties for these elements in a bean class or could someone help me with a source code for the bean class Formbean.
Thanks
[This message has been edited by rejieve alexander (edited March 01, 2001).]
 
padmaja mandava
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also new to Jsp. I think this will help you.
public class FormBean {
private String firstName;
private String lastName;
public void setFirstName(String FirstName) {

firstName = FirstName;
}
public void setLastName(String LastName) {
lastName = LastName;
}
public String getFirstName() {
return firstNama;
}
public String getLastName() {
return lastName;
}
}
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat has several good and simple examples, you can use them as your training class to learn some basics of JSP/JavaBean.
We use the numguess game as a training toy project for new team members.
The SCJD Development Team
[This message has been edited by Roseanne Zhang (edited March 01, 2001).]
 
rejieve alexander
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks padmaja,
But i did write a similar code to u'rs .
And while running the jsp file , i was getting
an error ..
Servlet Exception error..can't find property "firstName"
plz help... have i got to set some property in
my servlet class Formbean..how do i go about it???
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rejieve ,
Please take a look at this discussion.
http://www.javaranch.com/ubb/Forum7/HTML/002339.html
The minimum reqirements for a class to be a Javabean is ,
1. The .java file must have no-arg constructor.
2. if there is a property named "firstName" there must be corresponding
public void setFirstName(String fname) { }
public String getFirstName() { return this.firstName;} methods.
3. To make use of <jsp:useBean...... property="*"> , the request parameters names must exactly match the member var names of your bean java file including the upper/lower case.
Please take a look at the example in the above link's discussion.
regds
maha anna


[This message has been edited by maha anna (edited March 02, 2001).]
 
rejieve alexander
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks maha anna,
My doubts have been cleared thro' u'r explanation
and the example.
Bye for now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic