• 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

JSP Tags

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I want to display product prices on JSPs. This is how the prices are displayed:

If the current price of the product is less then the base price then display the base price striked out and the current price in red. Otherwise display the price as normal.

This has to be done on several pages. There is approx 10 lines of code to retreive the base price and the current price of the product, given a productId.

I was thinking of using JSP tags for this but at the same time I dont have much experience with tags.
Can somebody suggest a solution to this using tags?
Should the tag directly return the html to be displayed (red price & etc..)??

Thanks
Amit
 
Sheriff
Posts: 67746
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
This is a perfect application for a custom action (formerly known as "custom tags"). It's a display-support operation, which makes it appropriate for on-page use, and will be reused in multiple places and perhaps on multiple pages.

Such tags usually emit the HTML that they are "replacing".

If you are using a JSP 2.0 engine, this custom action might best be implemented as a tag file making use of the JSTL for your logic. Under JSP 1.2, you'll need to use the classic JSP Tag API.
 
Raj Mehta
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i am using JSP 1.2 so I cant use custom actions.

More precisely my question is should the TAG class be generating the HTML or as in my case should I just pass back two variables currentPrice, basePrice back to the parent jsp which should determine if the currentPrice is lower than the base price and handle the display accordingly??
 
Bear Bibeault
Sheriff
Posts: 67746
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

well i am using JSP 1.2 so I cant use custom actions.



Yes, you can. That was answered by: "Under JSP 1.2, you'll need to use the classic JSP Tag API."


More precisely my question is should the TAG class be generating the HTML



And that was answered by: "Such tags usually emit the HTML that they are 'replacing'."
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic