Developing Web Applications, Servlets, and JSPs for WebLogic Server
BEA provides three specialized JSP tags that you can use in your JSP pages:
process. These tags are packaged in a tag library jar file called
weblogic-tags.jar. This jar file contains classes for the tags and a tag library descriptor (TLD). To use these tags, you copy this jar file to the Web application that contains your JSPs and reference the tag library in your JSP.
weblogic-tags.jarfile from the
extdirectory of your WebLogic Server installation to the
WEB-INF/libdirectory of the Web application containing the JSPs that will use the WebLogic Custom Tags.
<taglib>element of the J2EE standard Web application deployment descriptor,
The cache tag enables caching the work that is done within the body of the tag. It supports both output (transform) data and input (calculated) data. Output caching refers to the content generated by the code within the tag. Input caching refers to the values to which variables are set by the code within the tag. Output caching is useful when the final form of the content is the important thing to cache. Input caching is important when the view of the data can vary independently of the data calculated within the tag.
If one client is already recalculating the contents of a cache and another client requests the same content it does not wait for the completion of the recalculation, instead it shows whatever information is already in the cache. This is to make sure that the web site does not come to a halt for all your users because a cache is being recalculated. Additionally, the async attribute means that no one, not even the user that initiates the cache recalculation waits.
Caches are stored using soft references to prevent the caching system from using too much system memory. Unfortunately, due to incompatibilities with the HotSpot VM and the Classic VM, soft references are not used when WebLogic Server is running within the HotSpot VM.
If you want all caches to be refreshed, set the cache to the application
scope. If you want all the caches for a user to be refreshed, set it in the
session scope. If you want all the caches in the current request to be refreshed, set the
_cache_refresh object either as a parameter or in the request.
<wl:cache> tag specifies content that must be updated each time it is displayed. The statements between the
</wl:cache> tags are only executed if the cache has expired or if any of the values of the key attributes (see the Cache Tag Attributes table) have changed.
Flushing a cache forces the cached values to be erased; the next time the cache is accessed, the values are recalculated. To flush a cache, set its
flush attribute to
true. The cache must be named using the
name attribute. If the cache has the
size attribute set, all values are flushed. If the cache sets the
key attribute but not the
size attribute, you can flush a specific cache by specifying its
key along with any other attributes required to uniquely identify the cache (such as
flushattribute in an empty tag (an empty tag ends with
/and does not use a closing tag). For example
Cache timeout property. The amount of time, in seconds, after which the statements within the cache tag are refreshed. This is not proactive; the value is refreshed only if it is requested. If you prefer to use a unit of time other than seconds, you can specify an alternate unit by postfixing the value with desired unit:
Specifies additional values to be used when evaluating whether to cache the values contained within the tags. Typically a given cache is identified by the cache name that you configured in web.xml. If that is not specified the request uri is used as a cache name. Using keys you can specify additional values to identify a tag. For example, if you want to separate out the cache for a given end user, then in addition to the cache name you can specify the keys as the userid, values for which you want to pick it up from the request parameter scope (query param/post params) plus perhaps a client ip. So you will specify your keys as: "
The list of keys is comma-separated. The value of this attribute is the name of the variable whose value you wish to use as a key into the cache. You can additionally specify a scope by prepending the name of the scope to the name. For example:
A unique name for the cache that allows caches to be shared across multiple JSP pages. This same buffer is used to store the data for all pages using the named cache. This attribute is useful for textually included pages that need cache sharing. If this attribute is not set, a unique name is chosen for the cache.
We recommended that you avoid manually calculating the name of the tag; the
For caches that use keys, the number of entries allowed. The default is an unlimited cache of keys. With a limited number of keys the tag uses a least-used system to order the cache. Changing the value of the size attribute of a cache that has already been used does not change the size of that cache.
In addition to caching the transformed output of the cache, you can also cache calculated values within the block. These variables are specified exactly the same way as the cache keys. This type of caching is called Input caching.
Variables are used to do input caching. When the cache is retrieved the variables are restored to the scope you specified. For example, for retrieving results from a database you used var1 from request parameter and var2 from session. When the cache is created the value of these variables are stored with the cache. The next time the cache is accessed these values are restored so you will be able to access them from their respective scopes. For example, var1 will be available from request and var2 from session.
<!--the content between these tags will only be</wl:cache>
refreshed on server restart-->
<wl:cache key="request.ticker" timeout="1m">
<!--get stock quote for whatever is in the request parameter ticker</wl:cache>
and display it, only update it every minute-->
<wl:cache key="parameter.isbn" timeout="1d" size="100">
<!--incoming parameter value isbn is the number used to lookup the
book in the database-->
<!--retrieve the book from the database and display</wl:cache>
the information -- the tag will cache the top 100
most accessed book descriptions-->
<wl:cache timeout="15m" async="true">
<!--get the new headlines from the database every 15 minutes and</wl:cache>
<!--do not let anyone see the pause while they are retrieved-->
<wl:process> tag for query parameter-based flow control. By using a combination of the tag's four attributes, you can selectively execute the statements between the
</wl:process> tags. The process tag may also be used to declaratively process the results of form submissions. By specifying conditions based on the values of request parameters you can include or not include JSP syntax on your page.
<!--Only show this if there is no update or delete parameter--><form action="<%= request.getRequestURI() %>">
<input type="text" name="name"/>
<input type="submit" name="update" value="Update"/>
<input type="submit" name="delete" value="Delete"/>
<wl:repeat> tag to iterate over many different types of sets, including Enumerations, Iterators, Collections, Arrays of Objects, Vectors, ResultSets, ResultSetMetaData, and the keys of a Hashtable. You can also just loop a certain number of times by using the
count attribute. Use the set attribute to specify the type of Java objects.