puzzling.org · mary.gardiner.id.au · Macquarie University

Outdated JSP and Resin tricks

This page was last substantially updated in late 2000, and any and all information might be well out of date.

Setting variable Content-type HTTP headers in JSP

You can't use <%@ page contentType="text/blah" %> to do this - it won't be evaluted in the control flow of your code. Instead only the last page directive mentioned in the entire file will hold. However:

There is a response variable of class HttpServletResponse automatically accessible to each JSP page instance. It has a method setHeader(String header-name, String header-content) you can use to set Content-type, among other headers, and being straight Java-code, it is subject to the control flow of the code.
There's also a request object of class HttpServletRequest but I found out about it much more easily for some reason.
Seek the javadocs for more info.

Mysterious lack of database access by Resin

I don't know if this happens with Resin in total, or just a particular version running in conjunction with IIS, but if you've highlighted any text in the output window it won't write to it, and database access won't complete. Cease highlighting. Silly, I know.

Resin returns ClassNotDef errors for user-defined classes

It can find them... it just can't interpret the byte-code. Your compiler doesn't match the runtime environment's version, most likely.

Last modified: 25 June 2003