File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSTL + custom tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL + custom tags" Watch "JSTL + custom tags" New topic
Author

JSTL + custom tags

Jorge Blaz
Ranch Hand

Joined: Jan 31, 2004
Posts: 53
Hello,

I want to pass a dynamic property to a custom tag. I'm using JSTL 1.0 + Jsp 1.2

I've tried this, but none of the above seem to work:

<mytag:city postalCode="<c ut value='${myCode}' />" />
<mytag:city postalCode="${myCode}" />

Any ideas of how to do this?. (the "myCode" variable is stored in page context)

Thanks in advance.
Jorge
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61772
    
  67

In JSP 2.0 your second example will work just fine since the EL is evaluated by the JSP container.

Under JSP 1.2 you're kinda stuck because the EL is only interpreted by the JSTL tags.

Here are some options:

1) Evaluate the EL expression within your tag using the JSTL API. I've not done this (since I use JSP 2.0) so I don't know how hairy it is.

2) Do something like:


where you tell the tag how to look up the value in the scoped variables.

3) Punt back to scriptlet expressions:



4) Upgrade to Tomcat 5 and JSP 2.0/JSTL 1.1.


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

Joined: Jan 10, 2002
Posts: 61772
    
  67

Btw, your topic title would better have been "EL and custom tags".
Jorge Blaz
Ranch Hand

Joined: Jan 31, 2004
Posts: 53
The best option would be number 1, but it will be hard to find examples
of how to do this.

Options 3 and 4 are good but I must use JSP 1.2 and I try to avoid scriptlets by using JSTL and custom tags.

So, i will try to do it with option 2.

Thanks for the help Bear, and you're right, the title should have been better EL and custom tags.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL + custom tags