This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes Something Fishy about JSTL Tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Something Fishy about JSTL Tags" Watch "Something Fishy about JSTL Tags" New topic
Author

Something Fishy about JSTL Tags

Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
I was using "Apache Standard Taglib Standard 1.1" for setting different resource bundle based on the user. I also added default resource bundle name in web.xml as below.


I was using setBundle tag in my code so that it will set different bundle based on the user.



I tried to set the scope in the setBundle tag, but in "Apache Standard Taglib Standard 1.1" it was throwing an exception saying that var argument need to be used when you are using the scope variable …

Error: passiontemplate1.jsp:31:1: The page failed validation from validator: "Illegal scope attribute without var in "fmt:setBundle" tag.".
Then I was running the code without scope variable, but the setBundle was not overriding the default build name (which is specified in the web.xml)



When I was debugging the code of the JSTL Message Tag (org.apache.taglibs.standard.tag.rt.fmt.MessageTag), they are getting the bundle name from the pageContext .Below is the code which searches the bundle name.

Code Snipped from javax.servlet.jsp.jstl.core.Config


I have two questions which are running in my mind.

Why fmt:setBundle tag was not allowing to set the scope variable only?

As we defined the default resource bundle name in web.xml (which is application level), why the code was setting the bundle name in the pageContext?(it should set in the application scope).

And finally why they are started to search from pageContext à Application (I think it has to be reversed)?


Please let me know if you have any thoughts on this?


My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61449
    
  67

The scope attribute instructs the tag where to place the var attribute. It doesn't have any meaning without a specified var.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
Bear i think it will stil holds good with setBundle tag.. the reason is my message can use the bundle which was set in the different scope based on my requirments...i have learnt that it was bug in Apache Standard Taglib Standard 1.1..... in updated version we have option to set the bundle without any war arguments....
Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
The one thing which i can't understand is why they took from web.xml and storing in page context... is that the right way to do ???
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61449
    
  67

?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Something Fishy about JSTL Tags