i am trying to learn jsp, and when i include another .jsp file to my main page, its contents are not shown. here is the code
main.jsp
<html>
<head><title>the include action</title></head>
<body>
<center>
<h2>the include</h2>
<jsp:include page="/date.jsp"/ >
</center>
</body>
</html>
date.jsp
<p>
Today's date: <%= (new java.util.Date()).toLocaleString()%>
</p>
include like this
<jsp:include page="date.jsp"></jsp:include>
or use this at top of your jsp
<%@ include file="date.jsp" %>
Try using import statement,If your current page and date.jsp are in same folder.
<c:import url="date.jsp" >
instead of
<jsp:include page="/date.jsp"/ >
N.B: Before using c taglib, import it first and include jstl.jar and standard.jar to your classpath.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With