jsp:include using subdirectories

N

news

Why doesn't this work:

<jsp:include page="/WEB-INF/classes/jspbeans/testdata.txt"/>


while this does?:

<%@ include file="/WEB-INF/classes/jspbeans/testdata.txt" %>


The problem is that the txt file changes and I want to incorporate the
changes each time the jsp reloads.
 
W

Wendy S

news said:
Why doesn't this work:
<jsp:include page="/WEB-INF/classes/jspbeans/testdata.txt"/>
while this does?:
<%@ include file="/WEB-INF/classes/jspbeans/testdata.txt" %>
The problem is that the txt file changes and I want to incorporate the
changes each time the jsp reloads.

Because one happens at compile time, and the other at run time. So use <%@
include since that's what works.
(It doesn't have anything to do with subdirectories.)
 
T

Tor Iver Wilhelmsen

news said:
<jsp:include page="/WEB-INF/classes/jspbeans/testdata.txt"/>

This is an alias for RequestDispatcher.include() and can only see what
that API can see. Try using "//WEB-INF..."
<%@ include file="/WEB-INF/classes/jspbeans/testdata.txt" %>

This evaluates at compile-time and "sees" everything that the compiler
sees. It has two disadvantages, changes to testdata.txt after the JSP
is compiled will be ignored, and the synthesized _jsp_service() method
will become bigger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top