• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is this an okay way to do this? scripplets.

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been told to minimize my use of scriptlets in view JSPs.

Now if I define a bean in my JSP page is it okay to do it like this?



or is there a better way?
would be a scriptlet right?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my view your use of a small scriptlet to access a static property is perfectly fine. JSTL tags don't really work well with static methods or properties, and using a scriptlet is the most intuitive way to access them that involves the least amount of coding. As with anything, the "No Scriptlets" mandate can be taken to an extreme and get in the way of doing things in the most effective and efficient way.
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is where JSTL implicit objects come into play. you can use the 'sessionScope' object rather than defining the bean. the only trick is that you CANNOT use the constant variable as your 'getter' and must use the value of the static constant. this assumes you are using JSTL.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic