2

i have learned jsp native, i want to include dynamic file. i want to call dynamic page using include

this code

<% String p = request.getParameter("p"); %>

            <%@ include file="pages/"+p+".jsp" %>

if i type dashboard.jsp?p=about the page open "pages/about.jsp"

if i type dashboard.jsp?p=product the page open "pages/product .jsp"

in php this script like this

$p= $_GET['p'];
include(pages/'.$p.'.php');
MaDHaN MinHo
  • 529
  • 7
  • 23
Maestro Vladimir
  • 1,186
  • 4
  • 18
  • 38

2 Answers2

5

Similar question Include file from dynamic property value

In your case

<% String p = request.getParameter("p"); 
   String pagePath = "pages/" + p + ".jsp";
%>

<jsp:include page="<%= pagePath %>" ></jsp:include>
Community
  • 1
  • 1
1

You can Try this code

<%String p="pages/"+request.getParameter("p")+".jsp" %>
<jsp:include page="<%=p %>">
</jsp:include>

instead of this code

<%@ include file="pages/"+p+".jsp" %>
MaDHaN MinHo
  • 529
  • 7
  • 23