So lets get started!!!
Accessing a Declared JavaBean Component
We know how to declare a JavaBean and use it. But, there is one extra thing, there are many ways of using these beans. We can access them using scriptlets or expressions or xml elements. Let us see examples about each of these ways.
Example: Accessing a Bean Property
Using XML:
< jsp : getProperty name = “addressBean” property = “city” … / >
Using Scriptlets:
< % String city = objAddress.getCity() % >
Using Expression:
< % = objAddress.getCity() % >
Exam Trivia
Question: What are the three ways to reference a bean in JSP?
Answer: A JavaBean can be referenced in three ways: through an expression, scriptlet, or XML tag.
Previous Chapter: Chapter 42 - JavaBeans Scope
Next Chapter: Quick Recap - Chapters 38 to 43
No comments:
Post a Comment