users@glassfish.java.net

Re: Enable Browser Cache for JSP?

From: emiddio-frontier <emiddio_at_frontier.com>
Date: Mon, 04 Jul 2011 13:57:58 -0700

also --jsp always dynamically generates the page -- the jsp get
translated into a servlet.

so i think the servlet will always consider that it has a fresh page for
the browser.

you could compile the jsp to get translated to into a java servlet -
then deploy that servlet rather
than the jsp page and then modify the generated servlet java code to
implement/override
javax.servlet.http.HttpServlet.getLastModified(HttpServletRequest req)
to return the time you
last changed the page --and then the browser can use its cache.

gary



On 7/4/2011 10:32 AM, emiddio-frontier wrote:
> sounds like you page scope is not Session --
>
> you would also need to have logic that knows the database has been
> read so it does
> not do it again.
>
> if you set a break point at your database read code -- and that code
> is being
> called more than once -- then its not related to cache -- its your logic.
>
>
> gary
>
>
> On 7/4/2011 8:54 AM, forums_at_java.net wrote:
>> I have a jsp file that reads from a database to generate a page for the
>> user.
>>
>> The read is complex and slow, the is result large, so I don't want to
>> keep
>> generating and trasmitting the page back to the user.
>>
>> The page stays the same throughout the user's logon session, so it
>> doesn't
>> need regenerating anayway until the logouts/back on.
>>
>> How can I get the browser to cache the page and read from the cache
>> when the
>> user clicks on a link to that page?
>>
>> I have tried setting the Cache-Cotrol header to public with a
>> max-age, but
>> this hasnot helped.
>>
>> Any ideas? Thanks.
>>
>>
>> --
>>
>> [Message sent by forum member 'abenz']
>>
>> View Post: http://forums.java.net/node/818691
>>
>>
>>
>
>