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..)??
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.
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??