tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Bergsten <h...@gefionsoftware.com>
Subject Re: AW: [PATCH REPOST] Tomcat 4.0 JSP Examples view Source
Date Sat, 02 Dec 2000 01:26:50 GMT
Pierre Delisle wrote:
> [...]
> > All other examples execute the JSP if I hit Source. I can also let the
> > example execute
> > when I hit 'Execute'.
> 
> The 'Execute' link points to the jsp file itself (so the page is executed
> when the link is selected), while the 'source' link points to an html file,
> which itself displays a link that points to a .txt file containing the source code.
> (so the source code is displayed when the link is selected).

I bet this problem only occurs with IE. It tries to be smarter than the server,
and totally ignores the Content-Type header. Instead it looks for HTML
elements in the response body, and if it finds one it tries to render
the response as HTML. Since the .txt file contains both HTML and JSP
elements, the result is that IE shows a rendering of the HTML and hides
all JSP elements :-(

I have attached a hack I use to show the source for all example pages
in my upcoming JSP book. Use it if you like. It takes the JSP source file 
and converts all HTML special characters into HTLM character entities. IE can 
then happily render it as HTML.

To use it, just map it to a name (e.g. jspSource) and use a URI like 
/jspSource/<context-relative-path-to-JSP-page>.

Note! Even though it does test the path for ".." and "WEB-INF", I can't
guarantee that it handles all possible security threats. In other words,
this servlet should *not* be installed on a production site.

Hans
-- 
Hans Bergsten		hans@gefionsoftware.com
Gefion Software		http://www.gefionsoftware.com
Mime
View raw message