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

Model 2 Question  RSS feed

 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-ssj-jspmvc.html
According to this article the servlet creates the instance of JavaBeans in Model 2. There could be multiple instances of beans for each request/user. I was wondering how the JSP will know which instance of JavaBeans it should use. Any explaination ? Thanks
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlets can use an appropriate scope depending on the data they're attempting to expose. For instance, a servlet can insert data into its current ServletRequest object, or the HttpSession or ServletContext. The JSP page accesses these by virtue of the various scopes it has access to -- e.g., either
<%= session.getAttribute("foo") %>
in a scriptlet or
${sessionScope.foo}
in JSTL.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!