Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Purpose of using the Java Beans in JSP?

 
Ranch Hand
Posts: 35
Google Web Toolkit PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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="" />
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks now i understand when and where to use this. Thanks for your post reply!!
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply!! and you are right!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic