You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by James Watkin <ja...@anderson.ucla.edu> on 2006/01/19 02:20:15 UTC

fmt:setBundle Performance Pattern?

I'm revisiting some of my old JSP/JSTL code. I found that I used the 
following pattern because I must of thought it was a good idea for 
performance reasons. Do you think the test condition is really 
necessary? If I don't do the test, will every page hit reload the 
properties file, possibly from disk?

On every page*, should I use this:

<c:if test="${not applicationScope.bundleInitialized}">
     <fmt:setBundle scope="application" basename="ApplicationResources"/>
     <c:set var="bundleInitialized" scope="application" value="${true}"/>
</c:if>

or should I just use this instead?:

<fmt:setBundle scope="application" basename="ApplicationResources"/>

* I actually wouldn't have to explicitly put either option on every 
page, I could include or import it from a separate file.

- Jim

______________________________
James Watkin
ACIS Software Development
UCLA Anderson School
james.watkin@anderson.ucla.edu
Voice: 1-310-825-5030
   Fax: 1-310-825-4835
______________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: fmt:setBundle Performance Pattern?

Posted by James Watkin <ja...@anderson.ucla.edu>.
Thanks for the info. I missed that. My new project is a portlet, my 
first one. I'll look to see if that's possible with portlets.

- Jim

Kris Schneider wrote:
> Ignoring the performance question for the moment, if that's your app's 
> default bundle, why not just use:
> 
> <web-app>
>   ...
>   <context-param>
>     <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
>     <param-value>ApplicationResources</param-value>
>   </context-param>
>   ...
> </web-app>
> 
> That way you don't have to worry about explicitly setting the bundle on 
> the pages where you want to use it. Read through Chapter 8 of the JSTL 
> 1.1 Spec.
> 
> Getting back to performance, I think you'll find that once the bundle is 
> loaded, it's actually cached so it won't get reloaded. You can test this 
> out by hitting a JSP that uses the bundle, then editing the bundle and 
> seeing if the changes are reflected in the app.
> 
> James Watkin wrote:
> 
>> I'm revisiting some of my old JSP/JSTL code. I found that I used the 
>> following pattern because I must of thought it was a good idea for 
>> performance reasons. Do you think the test condition is really 
>> necessary? If I don't do the test, will every page hit reload the 
>> properties file, possibly from disk?
>>
>> On every page*, should I use this:
>>
>> <c:if test="${not applicationScope.bundleInitialized}">
>>     <fmt:setBundle scope="application" basename="ApplicationResources"/>
>>     <c:set var="bundleInitialized" scope="application" value="${true}"/>
>> </c:if>
>>
>> or should I just use this instead?:
>>
>> <fmt:setBundle scope="application" basename="ApplicationResources"/>
>>
>> * I actually wouldn't have to explicitly put either option on every 
>> page, I could include or import it from a separate file.
>>
>> - Jim
>>
>> ______________________________
>> James Watkin
>> ACIS Software Development
>> UCLA Anderson School
>> james.watkin@anderson.ucla.edu
>> Voice: 1-310-825-5030
>>   Fax: 1-310-825-4835
>> ______________________________
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 

-- 
______________________________
James Watkin
ACIS Software Development
UCLA Anderson School
james.watkin@anderson.ucla.edu
Voice: 1-310-825-5030
   Fax: 1-310-825-4835
______________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: fmt:setBundle Performance Pattern?

Posted by Kris Schneider <kr...@dotech.com>.
Ignoring the performance question for the moment, if that's your app's 
default bundle, why not just use:

<web-app>
   ...
   <context-param>
     <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
     <param-value>ApplicationResources</param-value>
   </context-param>
   ...
</web-app>

That way you don't have to worry about explicitly setting the bundle on the 
pages where you want to use it. Read through Chapter 8 of the JSTL 1.1 Spec.

Getting back to performance, I think you'll find that once the bundle is 
loaded, it's actually cached so it won't get reloaded. You can test this 
out by hitting a JSP that uses the bundle, then editing the bundle and 
seeing if the changes are reflected in the app.

James Watkin wrote:
> I'm revisiting some of my old JSP/JSTL code. I found that I used the 
> following pattern because I must of thought it was a good idea for 
> performance reasons. Do you think the test condition is really 
> necessary? If I don't do the test, will every page hit reload the 
> properties file, possibly from disk?
> 
> On every page*, should I use this:
> 
> <c:if test="${not applicationScope.bundleInitialized}">
>     <fmt:setBundle scope="application" basename="ApplicationResources"/>
>     <c:set var="bundleInitialized" scope="application" value="${true}"/>
> </c:if>
> 
> or should I just use this instead?:
> 
> <fmt:setBundle scope="application" basename="ApplicationResources"/>
> 
> * I actually wouldn't have to explicitly put either option on every 
> page, I could include or import it from a separate file.
> 
> - Jim
> 
> ______________________________
> James Watkin
> ACIS Software Development
> UCLA Anderson School
> james.watkin@anderson.ucla.edu
> Voice: 1-310-825-5030
>   Fax: 1-310-825-4835
> ______________________________
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org