Skip to content

Instantly share code, notes, and snippets.

@japaz
Created March 3, 2011 15:41
Show Gist options
  • Save japaz/852959 to your computer and use it in GitHub Desktop.
Save japaz/852959 to your computer and use it in GitHub Desktop.
Example jsp include from other context
<%@page import="javax.servlet.ServletContext" %>
<%@page import="javax.servlet.RequestDispatcher" %>
<%
ServletContext servletcontext = pageContext.getServletContext();
ServletContext servletcontext1 = servletcontext.getContext("/testAPP/v/a.jsp");
if (servletcontext1 != null) {
out.println("SC is not null");
RequestDispatcher requestdispatcher = servletcontext1.getRequestDispatcher("/v/a.jsp");
if (requestdispatcher != null){
out.println("RD is not null");
requestdispatcher.include(request,response);
} else {
out.println("RD is null");
}
} else {
out.println("SC is null");
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment