This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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.
arul murug
Greenhorn
Joined: Aug 08, 2002
Posts: 24
posted
0
Hi You can�t include the output of a servlet using static include. Try using dynamic include like this <jsp:include page="servlet/....">
SCJP2<br />SCWCD<br />UML & OOAD - IBM 486
verduka fox
Ranch Hand
Joined: Jan 18, 2001
Posts: 178
posted
0
I tried changing my code to:
and received this error: javax.servlet.ServletException: ERROR: Cannot forward. The response has already be en committed. Please advise. Thanks in advance.
arul murug
Greenhorn
Joined: Aug 08, 2002
Posts: 24
posted
0
Hi umm..I am not sure whether response will be comitted when you add "flush=true".I think it shouldn't. May be you can try removing "flush=true".
Arul
verduka fox
Ranch Hand
Joined: Jan 18, 2001
Posts: 178
posted
0
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" />
Any other ideas?
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
posted
0
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.
arul murug
Greenhorn
Joined: Aug 08, 2002
Posts: 24
posted
0
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.