• Post Reply Bookmark Topic Watch Topic
  • New Topic

Purpose of using the Java Beans in JSP?

 
Raga Jana
Ranch Hand
Posts: 35
Google Web Toolkit Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm learning the JSP. After i studied some important concepts in JSP. I have a doubt. Why i have to use Java Beans in JSP? For Example
i'm filling the form and i can get the value of the form fields by using the easy expression or normal method. But when it's going to beans first i have to set the property and then i can get the value. Why this much complexity? Or i misunderstood the concept?? or is any necessary we have to use this??

Exp Method : <%= request.getParameter("fieldname") %>

Beans Method : <jsp:useBeans type="" class="" id="">
<jsp:setProperty name="" property="" param="" />
</jsp:useBeans>
<jsp:getProperty name="" property="" />
 
Jatin Vij
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are quite correct to state that javabeans need not be used everywhere. Your example is a good illustration of when not to use a javabean in a JSP.
That being said, as applications become bigger and business logic grows more complex then javabeans are a good option.

Here's what Sun says about this (take it away Ora-Sun) : <http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans3.html#62132>
 
Raga Jana
Ranch Hand
Posts: 35
Google Web Toolkit Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks now i understand when and where to use this. Thanks for your post reply!!
 
Valery Lezhebokov
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your example - using scriplets in JSP is considered as bad practice, that is why use EL to access parameters:
 
Raga Jana
Ranch Hand
Posts: 35
Google Web Toolkit Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!! and you are right!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!