[Last Call] Learn how to a build a cloud-first strategyRegister Now


JSP tags

Posted on 2006-06-06
Medium Priority
Last Modified: 2013-11-24

What is the jsp:useBean class id and scope used for?

What is the jsp:setProperty name property and param for too?

Question by:jedistar
  • 3
LVL 86

Expert Comment

ID: 16843421

Expert Comment

ID: 16843460
LVL 10

Accepted Solution

mukundha_expert earned 1000 total points
ID: 16846074
<jsp:useBean class = "ClassName" ID = "instanceName" >

is equivalent to your java code

  ClassName instanceName = new ClassName ();

you can reference the instanceName Object in ur jsp according to the scope u give.

<jsp:setProperty name = "instanceName" property = "beanProperty" param = "data1">

is equivalent to calling the setBeanProperty method as shown below,
instanceName.setbeanProperty ( data1 );

similarly jsp:getProperty  tag is used to access the properties of the bean
LVL 10

Expert Comment

ID: 16846121
supose u ve a customer bean say
Customer { name,  age, address } with all getters and setters for that.

you have a html form contining all the fields of customer in that. when you submit it to your jsp, the JSP can map the input paramters ( form values ) directly to the bean using these tags.

suppose if your form fields also have the same names as of customer ( name,age,address )

you can call

   <jsp:useBean class = "Customer" ID = "customer" >
  <jsp:setPropert name = "customer" property = "*" />

the tags above will create a beanInstance customer and name,age,address are set to the values as specified in the form.

LVL 10

Expert Comment

ID: 16846153
Forgot to mention the SCOPE .

it can be page,request or session

if its page scope then the bean will be available only in that page
if it is request scope then the bean will be available only in the request
if it is session scope then the bean is available throught the session.

the default scope is page scope

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question