Artmal
Artmal

Reputation: 388

jsp:include doesn't make new requests to get updated file

I'm trying to understand what jsp:include does and from Oracle Tutorial I found out that:

The jsp:include element is processed when a JSP page is executed. The include action allows you to include either a static or a dynamic resource in a JSP file. The results of including static and dynamic resources are quite different. If the resource is static, its content is inserted into the calling JSP file. If the resource is dynamic, the request is sent to the included resource, the included page is executed, and then the result is included in the response from the calling JSP page.

So I expected the kind of behavior: one jsp page(first) is included in another(second) -> if I change content of first page on my server and refresh second page I will see some changes. But it seems that it doesn't work.

I have includes.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <jsp:include page="manipulations.jsp" />
</body>
</html>

My manipulations.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <p>I love Java</p>
</body>
</html>

Project structure:

Project structure

Firstly, I access includes.jsp(localhost:8080/includes.jsp) and see text "I love Java". Then I change text in file manipulations.jsp("I love Java" -> "I love JSP") and save it. Then I refresh includes.jsp and see no changes(still "I love Java"). Why is this happening? Am I wrong in understanding this element?

Upvotes: 1

Views: 1707

Answers (1)

Jonathan Laliberte
Jonathan Laliberte

Reputation: 2725

Does the problem persist even if you use a directive instead?

<%@include file="manipulations.jsp"%>

Try flushing:

<jsp:include page="manipulations.jsp" flush="true" />

If any of that doesn't work then i think the problem is with your cache settings. I'd be willing to put good money on the idea that the content will update if you restart your server each time and clean/rebuild/refresh.

Upvotes: 0

Related Questions