• 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

taglib to scriptlet attempt

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a taglib here that works great.


Now I would like to eliminate the taglibs and do it with scriptlet:


Please advise because it keeps giving me variable errors on my jsp after I try the scriplet attempt.
[ July 26, 2006: Message edited by: Ed Gretson ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is 'customers' in this line?

 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ed Gretson:

Now I would like to eliminate the taglibs and do it with scriptlet:



Umm, isn't that heading in the wrong direction?
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to show how ugly it can be in scriptlet code:



Thats as nice as I can make it.
I assumed that you were iterating over a list of Customer objects.
It means you have to import both the java.util and your Customer objects into the page.
If its an array, then cast it to an array (Customer[] I guess), and use standard loop for an array.

Replaced the forEach tag with a for loop using an Iterator.
Replaced ${expr} with <%= expr %>

All in all, the JSTL looks so much nicer don't you think?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic