Return to Vincent Partington's homepage

GNUJSPversion 0.9.6


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 release includes the possibility to use another java compiler (e.g. jikes) and compatibility with Servlet API specification 2.1. A number of administrative changes have also been made: the name has been changed, the Java package name has been changed, mailing lists have been set up, a public CVS server is available, the toolkit has been removed from the distribution and the homepage has moved.

Contents

  1. Installation
  2. Development
  3. More Information
  4. Version History
  5. Todo
  6. License

Installation

GNUJSP has been succesfully used 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 at http://www.xs4all.nl/~vincentp/download/.
  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:

  6. servlet.jsp.code=org.gjt.jsp.JSPServlet
    servlet.jsp.initArgs=classfiles=<dir for generated files>
  7. associate the extension .jsp with the newly configured servlet jsp.

  8. 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 parameters

GNUJSP can be configured with the following init parameters:
classfiles or compiler.classpath
This required parameter 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 (or compiler.classpath) init parameter to the servlets directory.
compiler
By default GNUJSP uses the builtin compiler of the JDK (javac) to compile the generated sources. Set this init parameter to a value like /usr/local/bin/jikes to use a different compiler.
compiler.options
This init parameter can be used in conjunction with the compiler init parameter:
* If the compiler.options init parameter contains the parameter %classpath% then %classpath% will be replaced with the system classpath + the value of compiler.classpath.
* If the compiler.options init parameter contains %1 then %1 will be replaced by the name of the file to compile. If it does not contain %1 then the name of the file will be appended to the end of the options.
* If the compiler.options init parameter contains other items of the form %parameter% then the %parameter% will be replaced with the value of the init parameter obtained by compiler.parameter. If this init parameter does not exist then an exception will be thrown.
If you use jikes as your compiler, setting this to "-classpath %classpath% +E +V" will allow GNUJSP to correctly translate the error messages.
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 parameter 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 parameter 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 parameter 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 (available at http://www.xs4all.nl/~vincentp/gnujsp/jspspec091.tar.gz). 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:

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.

More Information

If you want to know more about GNUJSP, one of the following options may help you:
Frequently Asked Questions
I've set up a list of the most frequently asked questions at http://www.xs4all.nl/~vincentp/gnujsp/faq.html. I will update this list separately from the GNUJSP releases.
Mailing Lists
Tim Endres of the Giant Java Tree has kindly set up two mailing lists:
gnujsp-ann: a low volume list used for announcements related to GNUJSP. For subscription info and archives, please visit http://www.gjt.org/servlets/MailingLists/ListInfo.html/gnujsp-ann
gnujsp: a general mailing list about anything related to GNUJSP. For subscription info and archives, please visit
http://www.gjt.org/servlets/MailingLists/ListInfo.html/gnujsp
Public CVS Server
If you want to see the latest version of the GNUJSP code, you can have a look at the Giant Java Tree's public CVS server at
http://www.gjt.org/cgi-bin/cvswebgjt/cvswebgjt.cgi/java/org/gjt/jsp. If you want to participate in the GNUJSP project, the easiest way is to join the Giant Java Tree and use CVS.
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 my homepage (http://www.xs4all.nl/~vincentp/) for the latest version.

Version history

Version 0.9.6 (17 Dec 1998): 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

License

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



Copyright (C) 1998, Vincent Partington <vincentp@xs4all.nl>, Last Updated: 17 Dec 1998.