| Run:
| tagcode.jsp
| servletcode.jsp
| View:
| tagcode.jsp
|  | servletcode.jsp
| DemoCacheServlet.java
| Code Notes
| Test Policy Descriptor

### JSP Tag v.s. Java API
Here we present a simple JSP, tagcode.jsp, which uses the caching tags. It will cache the two fragments it displays. You can reload repeatedly, but the times displayed in the fragments will not change until the cached fragments expire. The first fragment will take 25 seconds before it expires. It gets that value from the test-policy descriptor's TTL value. The time value for the second fragment will change sooner (after 15 seconds) because we have overridden the test-policy with a new TTL value. To provide a comparison between the caching tag with the code you would have to write in a servlet (or a JSP which does not use the caching tag) we present a more involved JSP, servletcode.jsp, which you can run and view. We also present the source code for the equivalent servlet, DemoCacheServlet.java. Clearly, the JSP's are more concise and the JSP which uses the tag library is the easiest of all.