I got no reply to my first post (below), maybe I was too wordy, so here's a
short version of the Q:
If I include a JSP fragment within another JSP page like this:
<jsp:include page = "test.jsp" />
but the file "test.jsp" does not exist, should TC throw an Exception? Or
maybe an HTTP 404?
I have a case like this where TC ignores the include altogether, wondering
why no error reported by TC.
> -----Original Message-----
> From: Steve Kirk [mailto:[EMAIL PROTECTED]
> Sent: Friday 21 October 2005 18:57
> To: '[email protected]'
> Subject: Should a missing jsp:include target cause TC to
> throw an exception or HTTP error code?
>
>
>
> TC 5.5.9
> WinXP SP2
> JDK 1.5.0_02-b09
>
> My webapp framework is based around my own Invoker servlet,
> which response to every request via a generic JSP build page.
> This build page itself includes other files, as shown in
> this snippet:
>
> <jsp:include page = "<%= "layout/" + pageLayoutName +
> "_begin.jsp" %>" />
> <jsp:include page = "<%= jspPageName %>" />
> <jsp:include page = "<%= "layout/" + pageLayoutName +
> "_end.jsp" %>" />
>
> Each request to the webapp is received by a servlet, which
> forwards to the JSP snippetted above to render the response,
> and the JSP decides which JSPFs to assemble to customise the
> response layout according to the request.
>
> This all worked fine. Then I accidentally omitted 2 JSP
> fragment files from the war file when reorganising my code -
> the files referred to in lines 1 and 3 above. I would expect
> that to cause a runtime exception of some sort if the target
> files don't exist. (Right?) However, no exception is thrown.
> The build page (that calls the jsp:includes) just carries on
> and assembles the rest of the page, omitting the files that
> it can't find. Hmmmmm. Sort of nice that it doesn't
> complain, but also sort of worrying.
>
> Having had a brief look at the TC source, I focused on the
> source code of org.apache.jasper.servlet.JspServlet:279,
> which appears to show that if the jsp:include file cannot be
> found at the specified URI, then TC will return an HTTP 404
> status code in this situation, if I am understanding it correctly:
>
> // snippet from JspServlet#serviceJspFile
>
> if (null == context.getResource(jspUri))
> {
>
> response.sendError(HttpServletResponse.SC_NOT_FOUND, jspUri);
> // this is the line in the stacktrace
> return; // to calling JspServlet#service() method
> }
>
> But, the weird thing is, my current TC server does not appear
> to do that. Each page is returned with a SC of 200. No
> exceptions logged at all. The only defect is that the
> response pages don't include the two JSPF files.
>
> I'm concerned that I have done something to the config of my
> webapp that is suppressing the error somehow. But I also
> realise that I might have misinterpreted what I have read of
> the TC source files.
>
> So I have two questions please:
>
> Q1: have I understood correctly, that TC should throw an
> exception or HTTP SC if it can't find a jsp:include file when
> processing a JSP?
>
> Q2: what might I have done that could suppress this sort of error?
>
> There is more to this problem, but I won't post the next
> chapter because the answers to Q1 and Q2 might change what is
> relevant for me to post.
>
> Thanks.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]