This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Plz help..how to make a bean class

 
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).]
 
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;
}
}
 
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???
 
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
 
    Bookmark Topic Watch Topic
  • New Topic