zachary.com

personal pages

All ad proceeds donated to charity.

zJSP: Java Server Pages Translator

IMPORTANT This project is no longer actively maintained. I keep this page here for historical reasons. For an update on what I'm currently up to, see my weblog.

zJSP

A translator from Java Server Pages to Java servlets.

Download Version 0.3, September 1, 1998.

Introduction

zJSP is an experimental translator from Java Server Pages (jsp's) to Java. It is designed to be used in conjunction with Sun's Java Servlet Developers Kit (JSDK), version 2.0. It should work with any Java Servlet environment compatible with JSDK servlets. That said, I have only tested it against Apache 1.3, Apache JServ 0.9.11, and Sun JSDK 2.0.

zJSP is really intended to be an experiment. I assume that Sun, or someone else will eventually release a proper JSP environment. All I wanted to do was to play with Java Server Pages a bit right now. As such, zJSP is implemented as a page compiler, translating JSP pages into Java Servlets, which are then run using a Java Servlet environment.

What's New

Version 0.3 adds support for server-side inlcude files. A JSP file can now include another JSP file, using standard SSI syntax:

<!--#include FILE="file.inc"-->.

Don't put a space between the "-" and the "#", it won't work.

Version 0.2 added suport for the <BEAN> tag, so that you can now embed and reference Java Beans within your JSP pages. Full support for request parameter to Bean introspection is included as well. I don't have access to other working JSP implementations, so I'm not sure how well zJSP matches the intention of the JSP spec. Please let me know how it behaves for you.

Background

JSP, or JavaServer Pages, is a mechanism for writing HTML pages with embeded Java code. A full description can be found at Sun. zJSP implements much of the JSP spec (see Limitations, below), and is designed to be used as a pre-processor on JSP files. zJSP will translate these JSP's into Java Servlets, which can be run by standard Servlet environments.

Usage

Using zJSP is pretty easy. zJSP comes pre-compiles, but you can rebuild it if you want by executing "make all".

Included is a shell script ("zjsp") which will run the Java zJSP code. You must edit the file and update the ZJSP_HOME variable to point to the correct install directory.

Then just create a JSP file using your favorite editor, and run zjsp.

% zjsp foo.jsp

will produce "foo.java". You then compile foo.java as a java class. Be sure that the Java Servlet classes are on your CLASSPATH. The resultant file, foo.class, can then be run as you would any other Java Servlet.

Instuctions for setting up and running a Java Servlet environment are beyond the scope of this file. I use Apache and JServ. See the Java-Apache Project .

Limitations

zJSP is missing some important features. I hope to add many of these as time allows. Please feel free to help out and code what you can :-).

<PARAM> tags are not yet supported within <BEAN> blocks. Only session scoped beans are fully supported. Request scoped beans just exist for the lifetime of the service function.

Directive blocks may contain only a single directive. The JSP spec says that directives are specified as <%@ (directive="value")+ %>. zJSP can currenlty on parse a single directive within the <%@ %> block. You can of course just use multiple directive blocks.

Really bad error reporting. I intend to work on this next.

I can always use more exaples.

zJSP output servlets do not strictly match the JSP spec. In particular, zJSP servlets extend javax.servlet.http.HttpServlet, and by default implment

public void doGet( javax.servlet.http.ServletRequest, javax.servlet.http.ServletRespons );

Changes

Version 0.1 August 18, 1998: Initial public release

Version 0.2 August 25, 1998: Added tag support; Cleaned up parser quite a bit.

Version 0.3 September 1, 1998 Added server-side include ("<!--#include... -->") support; minor debug output cleanup

Copyright zJSP is Copyright (c) 1998, David Creemer. All rights not expressly granted in the LICENSE document are reserved. Please read the included LICENSE document.


This page last modified Thursday 08 February, 2007 by David Creemer
All content Copyright 2003-2005, David Z Creemer