I have a jsp file that currently includes 4 other files:
However, I now need to change these included files from .jspf's to servlets. Can servlets be included in JSP files? I have tried:
but I get an error: Bad file argument to include. I also prepended <%= request.getContextPath() %>/ before "servlet/com.mycompany.myproject.MyServlet" and received the same error. Please advise. Thanks in advance.
I removed the flush="true" part of the jsp include tag. This time I received this error on a 500 page: JSPG0080E: Invalid jsp:include tag: org.apache.jasper.JasperException: JSPG00 80E: Invalid jsp:include tag The code is: <td><jsp:include page="servlet/com.mycompany.myproject.MyServlet" /></td> Core Servlets and JavaServer Pages by Marty Hall says:
The jsp:include element has two required attributes, as shown in the sample below: page (a relative URL referencing the file to be included) and flush (which must have the value of true). <jsp:include page="Relative URL" flush="true" />
Is your servlet forwarding to a different URL? Remember, once you start writing to the output stream, you cannot forward. The JSP starts writing to the output stream, so when the servlet gets included and attempts to forward it will thorw that error.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
According to JSP specification, �flush� attribute in <jsp:include> is a optional attribute with �false� as default if don�t specify it. I am not sure in what context �Core Servlets and JavaServer Pages by Marty Hall says:� says. You don't need to give the flush attribute,but I don't know why you are invalid include exception.