Include another JSP file
You can use parameters like that
<jsp:include page='about.jsp'>
<jsp:param name="articleId" value=""/>
</jsp:include>
and
in about.jsp you can take the paramter
<%String leftAds = request.getParameter("articleId");%>
What you're doing is a static include. A static include is resolved at compile time, and may thus not use a parameter value, which is only known at execution time.
What you need is a dynamic include:
<jsp:include page="..." />
Note that you should use the JSP EL rather than scriptlets. It also seems that you're implementing a central controller with index.jsp. You should use a servlet to do that instead, and dispatch to the appropriate JSP from this servlet. Or better, use an existing MVC framework like Stripes or Spring MVC.
You can use Include Directives
<%
if(request.getParameter("p")!=null)
{
String p = request.getParameter("p");
%>
<%@include file="<%="includes/" + p +".jsp"%>"%>
<%
}
%>
or JSP Include Action
<%
if(request.getParameter("p")!=null)
{
String p = request.getParameter("p");
%>
<jsp:include page="<%="includes/"+p+".jsp"%>"/>
<%
}
%>
the different is include directive includes a file during the translation phase. while JSP Include Action includes a file at the time the page is requested
I recommend Spring MVC Framework as your controller to manipulate things. use url pattern instead of parameter.
example:
www.yourwebsite.com/products
instead of
www.yourwebsite.com/?p=products
Watch this video Spring MVC Framework