tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: JSTL Result Object and caching
Date Mon, 04 Nov 2002 19:05:51 GMT
Stefan wrote:
> Hans,
> 
> This using the Jakarta Cache object?

No, the example I showed you uses only JSTL actions and the standard
<jsp:useBean> action. The Cache tag library is something different.

Hans

> ----- Original Message -----
> From: "Hans Bergsten" <hans@gefionsoftware.com>
> To: "Tag Libraries Users List" <taglibs-user@jakarta.apache.org>
> Sent: Monday, November 04, 2002 1:06 PM
> Subject: Re: JSTL Result Object and caching
> 
> 
> 
>>Shawn Bayern wrote:
>>
>>>On Sun, 3 Nov 2002, Stefan wrote:
>>>
>>>
>>>
>>>>I am looking for information how the JSTL ResultObject deals with
>>>>caching of resultsets derived from a Javabean method that returned a
>>>>JDBC's rowset. When is the resultObject removed from memory, and/or
>>>>how (if it is cached), can it be controlled?
>>>
>>>
>>>There are really questions for the JVM, not for application developers.
>>>The object is eligible for removal once no references point to it; its
>>>space can be recovered as soon as a page that created it in page scope
>>>goes out of scope, for instance (or when a session expires, if it's
>>
> stored
> 
>>>in session scope -- and so forth).
>>>
>>>
>>>
>>>>In a situation where I have a resultset that is displayed in a jsp
>>>>using the JSTL <c:forEach> tag how can I set it up so that the
>>>>resultsObject persist for say 1 minute so that when the page is loaded
>>>>we don't have to go back to the database every time?
>>>
>>>
>>>This is a broader question; it's not the responsibility of the Result
>>>object to "cache" results in this fashion.  (It simply stores and
>>
> "caches"
> 
>>>results with a lifecycle associated with that of the object.)
>>>
>>>You can use the Jakarta Taglibs "Cache Taglib" -- or other projects'
>>>alternatives -- if you want open-ended, time-based caching.
>>>
>>
>>Adding another alternative, assuming you do the SQL query in the JSP
>>page. This is a simple caching technique I describe in my book, using
>>only JSTL and standard actions:
>>
>>   <!-- Set the chache period to one minute -->
>>   <c:set var="cachePeriod" value="${1 * 60 * 1000}" />
>>   <jsp:useBean id="now" class="java.util.Date" />
>>   <c:if test="${(now.time - cacheTime) > cachePeriod}">
>>     <sql:query var="result" scope="session" sql="..." />
>>     <c:set var="cacheTime" value="${now.time}" scope="session" />
>>   </c:if>
>>
>>This snippet makes sure you only access the database for a request
>>received at least one minute after the last time you processed the
>>query.
>>
>>If you access the database in a servlet or a bean instead, you
>>can translate this logic into Java code.
>>
>>Hans
>>--
>>Hans Bergsten hans@gefionsoftware.com
>>Gefion Software http://www.gefionsoftware.com
>>JavaServer Pages http://TheJSPBook.com
>>
>>
>>--
>>To unsubscribe, e-mail:
> 
> <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> 
>>For additional commands, e-mail:
> 
> <mailto:taglibs-user-help@jakarta.apache.org>
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>
> 

-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com
JavaServer Pages	http://TheJSPBook.com


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


Mime
View raw message