Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

fmt tag not working in error page  RSS feed

 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have the following jsp error page, which is invoked when a certain type of exception is thrown.



The page is being invoked correctly, however, the problem i am facing is that the "<fmt:message key="application.title" />" tag is not wking as it is supposed to do. Instead of dispalying the title of my application, it displays "???application.title???". I made sure that the message key "application.title" is in my message bundle, so this cannot be the cause of this problem.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sure *seems* like it's the problem.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the page know anything about your message bundle?
 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:How does the page know anything about your message bundle?

This is a good point. My message bundle is declared in my Spring xml config, so Spring takes care of finding the correct messages. However, the error page is directly declared in the web.xml, without any interference of Spring, so this is probably the cause of the messages not being found. Should i declare my message bundle in the error page? If so, what is the correct syntax for declaring a message bundle?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not recall off the top of my head. Consult the JSTL Specification.
 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the specification something like below should work.



However, nothing is being displayed (not even the ???applcation.title??? or ???error.system???). Inside my war files at the root of the WEB-INF dir there is a messages.properties file, so the message bundle should be found.
 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am kinda stuck on this one, so any help is much appreciated.

So far i've established that somehow i need to declare my message bundle and i have tried several options for doing this. I used <fmt:setBundle /> tag to declare the message bundle for the whole page, i enclosed my <fmt:message /> into an <fmt:bundle /> tag, but both did not have any result. Is there something that i have to declare in my web.xml before i can use the message bundle? I am under the impression that just declaring the bundle in the jsp is enough. Could someone give me a hint or pointer on where to look?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the messages were supposed to be on the classpath? I don't recall either, but this might help:

http://www.ibm.com/developerworks/java/library/j-jstl0415/#N10645
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your bundle on the classpath? Is the bundle name properly qualified within its package?

Here's an (abridged) example from my current project:
 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sure the message bundle is on the classpath, because it is in the root of my WEB-INF classes dir.
So using

should be okay.
 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Huh this is very strange! I just built my war again and deployed the application and now it is working like a sunshine!

Anyway, thanks everybody for your time and help.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Art Vandelay wrote:I am sure the message bundle is on the classpath, because it is in the root of my WEB-INF classes dir.

Just so you know, that is not what you said previously--it's quicker if we're working with correct information:
Inside my war files at the root of the WEB-INF dir there is a messages.properties file
 
Art Vandelay
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:
Art Vandelay wrote:I am sure the message bundle is on the classpath, because it is in the root of my WEB-INF classes dir.

Just so you know, that is not what you said previously--it's quicker if we're working with correct information:
Inside my war files at the root of the WEB-INF dir there is a messages.properties file

You're right, sorry for the confusion.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem :)
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!