BMS Robot Email wrote:
> Hello
>
> I want to #include a JSP page to present optional additional image files etc
> for a stock catalog application. The #include filename & path are
> constructed on the fly from stock/session information and the file may not
> exist at the time of generating the page, in which case I would like to use
> a "default" JSP for the image path etc.
>
> Currently this works fine when the JSP exists, however when it does not
> exist I am getting "404 Not Found" as part of the generated page - is there
> anyway in which the "404 Not Found" can be suppressed / replaced ?

Not with <jsp:include>, but the recently approved JSP Standard Tag
Library (JSTL) includes <c:import> and <c:catch> actions that can be
combined like this to do what you want:


   <c:catch var="error">
     <c:import url="${someResource}" />
   </c:catch>
   <c:if test="${error != null}">
     <%-- An exception or 404 resulted from the import --%>
     <c:import url="default.jsp" />
   </c:if>

For more about JSTL and the Reference Implementation, currently
in Beta, see:

   <http://java.sun.com/products/jsp/jstl/>

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

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

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to