GnuJSPversion 0.9.5

GnuJSP is a free implementation of Sun's Java Server Pages. Once the GnuJSP servlet is correctly installed, files with the extension .jsp are translated into java source files, compiled, and ran. This is an early release, intended for the adventurous. The JSP specification hasn't been fixed yet, and GnuJSP documentation is scarce, but you should be able to experiment with this exciting new technology!

This is a bugfix release. For the next version a lot will change (ideas are: adherence to the latest draft JSP specification (0.92),integration into the Giant Java Tree, page caching, use of JavaCC or Antrl for generation of the parser), so it is not yet certain whether the next version will be backward compatible, but I will try my best. Of course, I will indicate what needs to be done to update when we get there.

Contents

  1. Installation
  2. Development
  3. Feedback
  4. Version History
  5. Todo
  6. Copyright

Installation

GnuJSP has been tested with the following web server/servlet engine and OS/JDK combinations.

I would like know about other succesful combinations. Once more servlet engine/web server/OS platform combinations have been tested (and more time has been spent on writing the documentation), I want to have nice step-by-step installation guides here. For now, I will describe the general idea:

  1. download the latest version of GnuJSP (tar.gz or jar).
  2. unpack the downloaded file.
  3. add the GnuJSP jar file (lib/gnujsp.jar) to the classpath used by the servlet engine.
  4. create a directory to store the generated java and class files, that can be written by the servlet engine.
  5. configure the GnuJSP servlet like this:
    servlet.jsp.code=nl.nmg.jsp.JSPServlet
    servlet.jsp.initArgs=classfiles=
    <dir for generated files>
  6. associate the extension .jsp with the newly configured servlet jsp.
    For Apache JServ this means adding the following two lines to your srm.conf:
    AddHandler jsp-handler .jsp
    Action jsp-handler /servlet/jsp

Please note that you need JDK1.1 (or higher) to run GnuJSP. JRE will not suffice, because Sun's java compiler is called directly. Future versions may change this.

If installation was succesful, a file with the extension .jsp should be handled by the JSP servlet and ran. Copy the JSP examples in the directory examples to your web directory and try loading snoop.jsp.

Init arguments

GnuJSP can be configured with the following init arguments:

classfiles
This required argument specifies where GnuJSP should write the generated java and class files. If you want JSP pages to be able to use classes in the servlets directory (of the servlet engine), point the classfiles init argument to the servlets directory.
checkuri
By default jsp pages can be called either as /secure/file.jsp or as /servlet/jsp/secure/file.jsp. This is a security hole when when authentication is required to access the directory /secure, but not for /servlet. If the optional checkuri init argument is set to true, GnuJSP will not accept request that contain the strings "/servlet/" or "/jsp/".
extension
By default GnuJSP refuses to handle files whose extension is not .jsp. This required extension can be changed by setting the optional extension init argument to a different value.
pagebase
When determining the JSP file to compile, GnuJSP calls ServletContext.getRealPath(request.getServletPath()). If that fails to return a valid filename, GnuJSP tries request.getPathTranslated() instead. The optional pagebase init argument can be set to prefix the result of getPathTranslated() with a constant string. This can be useful when the servlet engine runs on a different server than the webserver.

Development

GnuJSP conforms to JSP draft specification 0.91 (previously available at http://developer.javasoft.com/developer/earlyAccess/jspages/). This draft is nearly identical to the JSP implementation in the JavaServer Pages preview pack, apart from the class and serializedfile attributes to the <BEAN> tag; GnuJSP follows the draft specification and calls these attributes type and beanName. The additions to the Servlet API (HttpServletRequest.setAttribute() and HttpServletResponse.callPage()) are not implemented by GnuJSP.

Additions

Awaiting the definitive JSP specification, GnuJSP adds a feature that is very useful to the JSP developer; file inclusion. Both the SSI and the JRun syntaxes are supported:

GnuJSP toolkit

As of version 0.9.4, GnuJSP comes with the GnuJSP toolkit. This is a collection of packages and classes to help in writing JSP pages, and servlets. The aim of the toolkit is to provide all kinds of useful utility routines without requiring anyone to learn the whole toolkit in one go. Instead, you can pick and mix the classes as you please. Feel free to suggest/make additions.

The GnuJSP does a lot of little things, but the major features are:

To find out more, check out the javadoc documenation.

Reloading and dependency checking

GnuJSP automatically detects changes to a JSP file (and the JSP files it includes), and recompiles the JSP file if necessary. When a change (or a new file) is detected, the JSP file is translated to a Java file, and javac is run. If javac reports any errors, GnuJSP does its best to translate the Java line numbers to JSP line numbers and reports the errors in the browser window.

Feedback

I'm very interested to hear what people think about GnuJSP and I'd like to hear about any problems you may be having with it, or suggestions you might have. Please email me at vincentp@xs4all.nl and check the webpage at http://www.nmg.nl/~vinny/gnujsp/ for the latest version.

Version history

Version 0.9.5 (11 Oct 1998):

Version 0.9.4 (23 Sep 1998):

Version 0.9.3 (15 Sep 1998):

Version 0.9.2 (12 Sep 1998):

Version 0.9.1 (5 Sep 1998):

Version 0.9.0 (27 Aug 1998):

Todo

Copyright

This software is distributed under the terms of the GNU Public License. Please see the file COPYING included with the distribution for details.