Mugdha Kulkarni wrote:
>
> Hi all,
> Tomcat gives me following exception while invoking my JSPs
>
> --org.apache.jasper.JasperException: Page directive: can't have multiple
> occurrences of info
>
> I have a JSP page which includes a number of JSPs. And obviously each of the
> included JSPs have their own page info directive. So the above error is
> occuring.
>
> Is there any solution for this ? Or do I have to remove Page info directive
> from all my included files ?
>
> Also Tomcat behaves similarly in case of error page directive and I have same
> problem with that also. All my included JSPs have their own error page
> directive. I have removed error page directive in each of the include file.
> But this is not a very good solution.
>
> Please let me know if there is any solution.

When you use the <%@ include ... %> directive, you are merging the source
of the included page with the source of the including page, so the
combination of all pages must be a valid JSP page. Therefore the pages
you include can not be complete JSP pages, with their own <%@ page %>
directives etc. They have to be JSP page fragments that makes sense
when merged with the including page.

If you want to include pages that you also need to be able to invoke
directly, you can use the <jsp:include> action instead. This ends up
being processed in the request phase (as opposed to the translation phase)
as an internal call to the target page. Instead of including the source
of the target page, you're including the response generated by the target
page. Here all pages are self contained and can have any directives you
like. One drawback with this approach in JSP 1.0/1.1 is that the response
buffer of the including page must be flushed before the target page
response is included. Flushing the response means that no more headers
can be set, so you can't set cookies, redirect, etc. after the include.
Error handling (forwarding to an errorPage) can also be messed up, since
it's not possible to forward after flushing the buffer. This problem
will hopefully be solved in the next rev of the spec.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to