Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes How can i use Beans? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can i use Beans?" Watch "How can i use Beans?" New topic

How can i use Beans?

Shahid Ali Naz

Joined: Mar 23, 2001
Posts: 3
con some body tell me about using beans like how to create beans compile and use for
example my task is implement a bean which give me the length of String
code is
public int len(String str)
return str.length();
how can i use on jsp or java programmes can u write bean on simple editor like java files and how can i complie and how i call from my main application

S.A Naz
Tony Alicea

Joined: Jan 30, 2000
Posts: 3226
First of all, your class does not look like an information bean with its method len. It should be getLen(String s) or getLength(String s)
Yes you can use a simple editor to write a Java bean. A Java bean is nothing more than a class with methods that follow some kind of convention in naming.
I am assuming that you mean Java beans in the server-side context and not in the visual context which requires considerably more programming.
Information on how to write beans is freely available from Sun at:

Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
I agree. Here's the link:
subject: How can i use Beans?
It's not a secret anymore!