It's not a secret anymore!*
The moose likes JSP and the fly likes Custom Tag Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom Tag Question" Watch "Custom Tag Question" New topic

Custom Tag Question

Vic Newman
Ranch Hand

Joined: Mar 01, 2002
Posts: 33
I want to be able to create reusable components for a page. For example a component that displays name and address information that i would be able to place on different pages without having to code the same thing on multiple pages. Can I do this with a custom tag? A simple example or link to an example would be appreciated. Thanks
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60800

Can I do this with a custom tag?


You didn't mention how the address data is making its way to the page, so I will assume you are using a modern Model 2 design.

Let's say that your servlet controller is placing an object of type Address that holds your address data onto the request as a scoped variable named "billingAddress", and another named "shippingAddress".

You could write a custom tag along the lines of:

which will spit out the approriate HTML-formatted data according to what it finds in the scoped variable identified by the "data" attribute.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
subject: Custom Tag Question
Similar Threads
Passing bundled resource as attribute to panel tag
CustomTag retrieving JSP page & url info
confusion with all front end technologies - what's in and what's out
knowing invoking JSP page name
Custom Tag in Servlet