Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Import & Usebean  RSS feed

 
Betsy Camel
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When shud i go for an import statement & usebean.
Whats the main difference between the two.whats the main purpose of the geter & setters
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the face of it, they are two different thinggies.

I think your question reframed would be 'When should I directly create a bean object by importing the class and instantiating it in my jsp as opposed to using the useBean functionality for the same '.

The first thing to know here is that useBean doesnt always create a bean instance .

In a standard MVC2 pattern, a request is received by a Servlet, which has handlers (classes) with methods that access the model and returns the data to the Servlet as a data transfer object.



The Servlet then places this data as a scoped attribute



Next it forwards the request to the jsp




The jsp, now uses useBean to retrieve the bean stored in request attribute by the servlet. A new bean is not created, provided the value of the "id" attribute matches the attribute name of the bean stored in request.
. The useBean functionality is to easily give you a handle to the bean object set in scope by the servlet and to access the data from the bean by way of jsp:getProperty.




You can read up more on MVC framework here.

cheers,
ram.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!