Score:0

How to stop tomcat from compiling jsp for single page app

bn flag

We have a server with tomcat 9 running on RedHat linux, and a vendor provided dynamic content management system that builds jsp pages to show news article types of content based on a query string parameter. So kind of a typical single page app, where the URL would look like https://domain/path/index.jsp?id=654321

And on the page we supply the underlying java code with the dynamic component that is using the id in the query string parameter, and this has historically worked.

<meta name="field_TcmId" content="@Component.Id.ItemId">
<meta name="field_Title" content="@Component.Fields.Title">

<div class="ng-hidden">
    <h1>@Component.Fields.Title</h1>
    <div>@Component.Fields.BodyText</div>
</div>

Now, though after a series of hardware and software updates, the first page load after it gets published shows the content as expected. Every time after that, we see the same cached version of content, and changes to the query string parameters don't seem to change the meta tag content or hidden fields the way we expect. The title is incorrect in the client browser tab.

We have tried disabling cache on client browsers, and enabling development for the servlet in the web.xml and configuring ExpiresFilter and ExpiresByType in the web.xml filter. We have tried increasing and decreasing and disabling caching in the context.xml for tomcat. We have tried configuring cache-control = no-cache for response headers, and an Expires response header.

I am wondering if tomcat is compiling the jsp on the first load after a page gets published and visited, and then, even though the query string parameters are changing for subsequent visits, meta tag values and hidden field values aren't being updated because the modified date is not getting updated.

kromaak avatar
bn flag
So, we found out that tomcat does a thing by default to try to reuse the resources for custom Java tags. In the tomcat web.xml there is a jsp servlet param called enablePooling. We resolved our issue by adding this to the jsp servlet and disabling it. `<init-param> <param-name>enablePooling</param-name> <param-value>false</param-value> </init-param>`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.