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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Custom Tag Question" Watch "Custom Tag Question" New topic
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 56207
    
  13

Can I do this with a custom tag?


Absolutely.

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Custom Tag Question
 
Similar Threads
knowing invoking JSP page name
Passing bundled resource as attribute to panel tag
Custom Tag in Servlet
CustomTag retrieving JSP page & url info
confusion with all front end technologies - what's in and what's out