I know that including and external file in jsp can be done with something like this:
<%@ include file="banner.jsp" %>
But is there a way of doing this inside a java class/object?
I know that including and external file in jsp can be done with something like this:
<%@ include file="banner.jsp" %>
But is there a way of doing this inside a java class/object?
You can do it inside a servlet (or any class having access to the current request), via the RequestDispatcher
:
request.getRequestDispatcher("/banner.jsp").include(request, response);
Note that you should rarely need to do this. It would mean that you are outputting view content from a servlet, and you should do that mainly in a jsp.
In Servlet you can call:
RequestDispatcher rd = request.getRequestDispatcher("include.jsp");
rd.include(request, response);