Two Laptop Bag
The moose likes JSP and the fly likes Custom tag in ResouceBundle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom tag in ResouceBundle" Watch "Custom tag in ResouceBundle" New topic

Custom tag in ResouceBundle

Kuniyoshi Kamimura

Joined: Sep 19, 2012
Posts: 1

Imagine there's a JSP code like below:

and it will be expanded as below:

Now I want to I18N this.

If you write like:

and the ResouceBundle is like:

then this will be expanded as below:

As you see, the custom tag is never expanded.

If you write like:

and the ResouceBundle is like:

of course it will be expanded as below:

But this word-to-word strategy is not applicable to I18N because some languages have different sequence of words.

What's the best solution?

I don't want to have multiple JSPs for each language.
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
As far as I am aware, it is not possible to produce JSP markup and have it interpreted in this manner - ie your <k:span> tags.
Those tags need to be in there at the time of jsp translation/compilation. They won't be evaluated if you output them via your JSP Writer.

So if I understand your purpose here, you want to apply markup tags to i18ned text.
Not a trivial thing.

The only approach that that even sounds remotely feasible is for you to write your own message tag, that would retrieve the translation from your message bundle, apply some custom logic to evaluate/expand that retrieved message, and then output it to the JSP.

No, its not standard at all, but it might be the only solution.

I agree. Here's the link:
subject: Custom tag in ResouceBundle
It's not a secret anymore!