Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JSP Tags

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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'."
 
eat bricks! HA! And here's another one! And a tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic