• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bean resources  RSS feed

 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been poking around the web looking for resources that talk about creating beans in Servlets, populating them, and handing them off to JSP.

Here is the best resource I have found so far:

http://courses.coreservlets.com/Course-Materials/pdf/csajsp2/14-MVC.pdf

If you come up with some more, please let me know. I find a lot about using beans on a JSP page, but very few which talk about using them from the servlet side in conjunction with the JSP side.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's the problem with most JSP resources on the web -- they act likes it's still 2002 and use older models of web application structure.

Basically the process is simple. The bean is instantiated in the servlet, placed onto request scope as a scoped vairable (using setAttribute), and the JSP is forwarded to.

If using the EL on the JSP, the bean can be referenced by the name used to create the scoped variable.

If the bean needs to have a longer life-time than the current request, it may be placed in session scope, but that should only be done when absoultely necessary. And there must be code to remove the session-scoped bean when its usefullness is over.

This article and this article touch on some of the considerations used when designing beans to send to a JSP.
[ November 14, 2006: Message edited by: Bear Bibeault ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!