0

i am a student i am doing a jsp project for my J2EE module.I choose a auction web site 4 my project. I have a doubt Can I use the java beans into a Servlet.I uses the Beans into my Jsp Page by using USEBEAN but how can i use the sanme bean into a Servlet.????.
Please Reaply me.
Thanks
thabo

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by peter_budo
0

Read and understand the java tutorial first of all.
You seem to have no grasp of what a javabean is, which means you don't understand the basics of the language.

0

Read and understand the java tutorial first of all.
You seem to have no grasp of what a javabean is, which means you don't understand the basics of the language.

i didnt yet understand what is bean...i also show some tutorials....can you give a small explanation about bean and how it is differ from servlet?and give and example for a form processing

1

JavaBeans are Java classes which adhere to an extremely simple coding convention. All you have to do is to implement java.io.Serializable interface, use a public empty argument constructor and provide public getter and setter methods to get and set the values of private variables ( properties )

Sample Example Code:

public class SimpleBean implements java.io.Serializable {

	/* Properties */
	private String name = null;
	private int age = 0;

	/* Empty Constructor */
	public SimpleBean() {}

	/* Getter and Setter Methods */
	public String getName() {
		return name;
	}

	public void setName(String s) {
		name = s;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int i) {
		age = i;
	}
}

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

Thank u Sapna Suresh.. But i have a doubt can we invoke some other user defined method into the beans?.Because you said the bean is a java class.... i want to make validation to my inputs..it means ,for an example i passes all the input value to a bean from the form i have made.i want to validate my inputs..can you explain this senario??please give a example cording for your explain...

0

Thank u Sapna Suresh.. But i have a doubt can we invoke some other user defined method into the beans?.Because you said the bean is a java class.... i want to make validation to my inputs..it means ,for an example i passes all the input value to a bean from the form i have made.i want to validate my inputs..can you explain this senario??please give a example cording for your explain...

Then you should seriously pick up some book and start learning as jwenting already recommended as you obviously do not have essential background

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.