wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP Custom Tags 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 "JSP Custom Tags" Watch "JSP Custom Tags" New topic
Author

JSP Custom Tags

Latha Reddy
Greenhorn

Joined: Aug 14, 2003
Posts: 12
Hi, I am new to JSP and have some doubt regarding Custom Tags.

Is there any way where we can get the custom tag result into a variable. I have a custom tag already written and I want to slightly manipulate the result based on some conditions.

Thank you very much,

Latha
[ October 06, 2004: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Welcome to the Ranch Latha.

Please note that I have done you the favor of removing the "URGENT" from your topic title. Be advised that most people here would regard that as rude and ignore your question. (And be honest, was your post really that urgent?)

In order to make best use of the resources here on the Ranch, I would advise you to not use phrases like "urgent" in your posts. The best way to make sure that your questions will get clear and helpful answers is to post clearly worded and thoughtfully asked questions.

bear
Forum bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Now on to your question: what exactly do you mean by "custom tag result"?

Am I correct to assume that you wish to populate or create a scripting variable from your tag(s)?
Latha Reddy
Greenhorn

Joined: Aug 14, 2003
Posts: 12
First, Sorry if I am not following your conventions of posting questions. But truly speaking, I am really looking for some help on this ASAP.

Let me explain my question clearly. I have a custom tag that gives a number(can be 0, +ve, or -ve). Now, I want to display a different text in the jsp page for different numbers that I obtain from the custom tag. How shoud i proceed?

Any help is highly appreciated.

Thanks,
Latha
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Are you using the JSTL? (If not, I highly recommend you do).
Latha Reddy
Greenhorn

Joined: Aug 14, 2003
Posts: 12
Any more ideas please. I am not sure of JSTL. Is there any other way where I can achieve this.

Thanks

Latha
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Yes, it's just a lot easier if you were already using JSTL.

Here's one way:

1) In your tag create a scripting variable and assign it the appropriate value. You can create the variable either via the "variable" declaration in the tag TLD, or with a TEI class. See a Custom Tag tutorial for specifics.

2) Be sure to specify that the scope of the variable is after the tag.

3) In your page use an if then else if then construct to switch between the various options based upon the value of the variable.
 
Consider Paul's rocket mass heater.
 
subject: JSP Custom Tags
 
Similar Threads
Include code in JSP
Process JSP Stream explicitly
How volume 2 will deal with custom tags?
head tag in JSP
How to write custom tag resulting In custom tags