[an error occurred while processing this directive]

Getting a Property value in jsp


This section illustrates you how to use <jsp:getProperty> tag.

To reduce the the scriplet code with jsp, there is an easier way of accessing properties of bean by using getProperty tag which automatically sends the result of the method. The tag <jsp:getProperty> has two attributes, name and property. Name attribute refers to the id of the bean and property attribute refers to the method of the bean. Here we are providing you an example which illustrates you the use of <jsp:getProperty> tag.

Here is the code of getProperty.jsp

<TITLE>Getting a Property Value</TITLE>
<H1>Getting a Property Value</H1>
<jsp:useBean id="bean" class="form.GetProperties" />
The text is: <jsp:getProperty name="bean" property="text" /> 

Here is the bean GetProperties.java

package form;
public class GetProperties
private String text="Hello World";
public String getText()
return text;
public GetProperties()

In the above example, we are using bean with <jsp:useBean> tag. <jsp:getProperty> tag calls the bean  and its method 'text' with its attributes id and property.

Here is the output

Download Source code


[an error occurred while processing this directive]