Re: Using bean:message from non-struts servlet
For posterity, and hopefully to help others, here's what James did: 1. Placed fmt:setBundle basename=package.name.to.messages.file.ClassName / near the top of the JSP, though I suspect the location might be irrelevant...not sure... 2. Used fmt:message key=key.name.in.properties.file/ to retrieve the specific resource message. -adam James Sanders wrote: Thank you Rahul, this was exactly what I needed. I was not formerly familiar with the fmt taglib. On 8/15/06, Rahul Akolkar [EMAIL PROTECTED] wrote: On 8/15/06, James Sanders [EMAIL PROTECTED] wrote: Puneet, Thank you for your response. The problem is that this does not work outside of the land of struts configuration. Using struts configuration, each jsp has access to all the keys in the Messages.properties file for its module (or actually, whichever module the ActionForm that forwards to that jsp is in). However, my servlet does not have a struts module and thus any jsp it forwards to has no inherent Messages.properties file from which to retrieve keys. It is possible to retrieve these keys from inside my servlet by using the ResourceBundle.getBundle() function with the argument being the fully qualified class name of the Messages.properties file. But when I try to access these keys from my jsp using the bean:message tag I get an error, leading me to believe that there must be some other place where the keys recognized by that tag are being populated, I simply don't know where. snip/ If your not in the Struts realm, use the JSTL format taglib (you may use it even if you are). The implementation details of the bean taglib depend on Struts specific APIs, such as MessageResources. -Rahul On 8/15/06, Puneet Lakhina [EMAIL PROTECTED] wrote: On 8/16/06, James Sanders [EMAIL PROTECTED] wrote: Working within a larger struts system, it became necessary for me to create a servlet, which co-exists with, but outside of, the system. This has worked very well, but I now find myself wishing to use the functionality of bean:message and MessageResource files in a jsp outside the struts realm. It is not difficult to simply use a ResourceBundle to retrieve the necessary messages into my servlet, but I can't seem to figure out how to make these messages accessible through bean:message in my jsp. Does anyone know the mechanism struts (or anything else) uses to make this happen? If you want to use a key from ur properties file in ur jsp, u could simply do.. bean:messgae key = some.key / this will put the value of the key here.. im not sure this wat u wanted to ask..but in case its this then well n good.. -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using bean:message from non-struts servlet
On 8/16/06, James Sanders [EMAIL PROTECTED] wrote: Working within a larger struts system, it became necessary for me to create a servlet, which co-exists with, but outside of, the system. This has worked very well, but I now find myself wishing to use the functionality of bean:message and MessageResource files in a jsp outside the struts realm. It is not difficult to simply use a ResourceBundle to retrieve the necessary messages into my servlet, but I can't seem to figure out how to make these messages accessible through bean:message in my jsp. Does anyone know the mechanism struts (or anything else) uses to make this happen? If you want to use a key from ur properties file in ur jsp, u could simply do.. bean:messgae key = some.key / this will put the value of the key here.. im not sure this wat u wanted to ask..but in case its this then well n good.. -- Puneet
Re: Using bean:message from non-struts servlet
Puneet, Thank you for your response. The problem is that this does not work outside of the land of struts configuration. Using struts configuration, each jsp has access to all the keys in the Messages.properties file for its module (or actually, whichever module the ActionForm that forwards to that jsp is in). However, my servlet does not have a struts module and thus any jsp it forwards to has no inherent Messages.properties file from which to retrieve keys. It is possible to retrieve these keys from inside my servlet by using the ResourceBundle.getBundle() function with the argument being the fully qualified class name of the Messages.properties file. But when I try to access these keys from my jsp using the bean:message tag I get an error, leading me to believe that there must be some other place where the keys recognized by that tag are being populated, I simply don't know where. On 8/15/06, Puneet Lakhina [EMAIL PROTECTED] wrote: On 8/16/06, James Sanders [EMAIL PROTECTED] wrote: Working within a larger struts system, it became necessary for me to create a servlet, which co-exists with, but outside of, the system. This has worked very well, but I now find myself wishing to use the functionality of bean:message and MessageResource files in a jsp outside the struts realm. It is not difficult to simply use a ResourceBundle to retrieve the necessary messages into my servlet, but I can't seem to figure out how to make these messages accessible through bean:message in my jsp. Does anyone know the mechanism struts (or anything else) uses to make this happen? If you want to use a key from ur properties file in ur jsp, u could simply do.. bean:messgae key = some.key / this will put the value of the key here.. im not sure this wat u wanted to ask..but in case its this then well n good.. -- Puneet
Re: Using bean:message from non-struts servlet
On 8/15/06, James Sanders [EMAIL PROTECTED] wrote: Puneet, Thank you for your response. The problem is that this does not work outside of the land of struts configuration. Using struts configuration, each jsp has access to all the keys in the Messages.properties file for its module (or actually, whichever module the ActionForm that forwards to that jsp is in). However, my servlet does not have a struts module and thus any jsp it forwards to has no inherent Messages.properties file from which to retrieve keys. It is possible to retrieve these keys from inside my servlet by using the ResourceBundle.getBundle() function with the argument being the fully qualified class name of the Messages.properties file. But when I try to access these keys from my jsp using the bean:message tag I get an error, leading me to believe that there must be some other place where the keys recognized by that tag are being populated, I simply don't know where. snip/ If your not in the Struts realm, use the JSTL format taglib (you may use it even if you are). The implementation details of the bean taglib depend on Struts specific APIs, such as MessageResources. -Rahul On 8/15/06, Puneet Lakhina [EMAIL PROTECTED] wrote: On 8/16/06, James Sanders [EMAIL PROTECTED] wrote: Working within a larger struts system, it became necessary for me to create a servlet, which co-exists with, but outside of, the system. This has worked very well, but I now find myself wishing to use the functionality of bean:message and MessageResource files in a jsp outside the struts realm. It is not difficult to simply use a ResourceBundle to retrieve the necessary messages into my servlet, but I can't seem to figure out how to make these messages accessible through bean:message in my jsp. Does anyone know the mechanism struts (or anything else) uses to make this happen? If you want to use a key from ur properties file in ur jsp, u could simply do.. bean:messgae key = some.key / this will put the value of the key here.. im not sure this wat u wanted to ask..but in case its this then well n good.. -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using bean:message from non-struts servlet
Thank you Rahul, this was exactly what I needed. I was not formerly familiar with the fmt taglib. On 8/15/06, Rahul Akolkar [EMAIL PROTECTED] wrote: On 8/15/06, James Sanders [EMAIL PROTECTED] wrote: Puneet, Thank you for your response. The problem is that this does not work outside of the land of struts configuration. Using struts configuration, each jsp has access to all the keys in the Messages.properties file for its module (or actually, whichever module the ActionForm that forwards to that jsp is in). However, my servlet does not have a struts module and thus any jsp it forwards to has no inherent Messages.properties file from which to retrieve keys. It is possible to retrieve these keys from inside my servlet by using the ResourceBundle.getBundle() function with the argument being the fully qualified class name of the Messages.properties file. But when I try to access these keys from my jsp using the bean:message tag I get an error, leading me to believe that there must be some other place where the keys recognized by that tag are being populated, I simply don't know where. snip/ If your not in the Struts realm, use the JSTL format taglib (you may use it even if you are). The implementation details of the bean taglib depend on Struts specific APIs, such as MessageResources. -Rahul On 8/15/06, Puneet Lakhina [EMAIL PROTECTED] wrote: On 8/16/06, James Sanders [EMAIL PROTECTED] wrote: Working within a larger struts system, it became necessary for me to create a servlet, which co-exists with, but outside of, the system. This has worked very well, but I now find myself wishing to use the functionality of bean:message and MessageResource files in a jsp outside the struts realm. It is not difficult to simply use a ResourceBundle to retrieve the necessary messages into my servlet, but I can't seem to figure out how to make these messages accessible through bean:message in my jsp. Does anyone know the mechanism struts (or anything else) uses to make this happen? If you want to use a key from ur properties file in ur jsp, u could simply do.. bean:messgae key = some.key / this will put the value of the key here.. im not sure this wat u wanted to ask..but in case its this then well n good.. -- Puneet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]