version 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
- Installation
- Development
- Feedback
- Version History
- Todo
- Copyright
Installation
GnuJSP has been tested with the following web server/servlet
engine and OS/JDK combinations.
- Apache 1.2.6, 1.3.1,
1.3.2/Apache JServ 0.9.11,
1.0b1
- Apache
1.3.0/LiveSoftware JRun
2.1.3
- Apache 1.3.1 for Win32/
LiveSoftware JRun 2.2a
- jo! 0.9.0
- Microsoft Internet
Information Server 3.0,
4.0/LiveSoftware JRun
2.1.3, 2.2a (Pro)
- Microsoft
Personal Web Server
4.0/LiveSoftware JRun
2.1.3
- Netscape
Enterprise Server
2.01/LiveSoftware JRun
2.2a
- Nexus
0.93
- Quid Pro
Quo 2.1/ServletExec
1.1.2, 2.0b1
- Sun
Java
Web Server 1.1.1, 1.1.2
- FreeBSD
2.1.5/FreeBSD JDK 1.1.5
V98-2-25
- Linux 2.0.30, 2.0.34,
2.0.35/Blackdown
JDK 1.1.6v2, 1.1.6v4
- MacOS 8.1/
MacOS Runtime for
Java 2.0, 2.1ea2
- Solaris 2.5,
2.6/Sun JDK
1.1.6
- Windows 95,
Windows
98/Sun JDK
1.1.5
- Windows
NT 4.0 Sp3/Sun
JDK 1.1.5, 1.1.6 w/JIT update, 1.2b4
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:
- download the latest version of GnuJSP
(tar.gz
or
jar).
- unpack the downloaded file.
- add the GnuJSP jar file (lib/gnujsp.jar) to the
classpath used by the servlet engine.
- create a directory to store the generated java and class
files, that can be written by the servlet engine.
- configure the GnuJSP servlet like this:
servlet.jsp.code=nl.nmg.jsp.JSPServlet
servlet.jsp.initArgs=classfiles=<dir for generated
files>
- 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:
- <!--#INCLUDE FILE="file"
--> and <%@ include="file"
%>: These tags include the contents of the specified file
at the current location in the JSP file. The filename is
interpreted relative to the JSP file containing the directive.
- <!--#INCLUDE VIRTUAL="uri"
--> and <%@ vinclude="uri"
%>: These tags include the contents of the specified file
at the current location in the JSP file. The uri is interpreted
relative to the JSP file containing the directive.
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):
- the directory containing the generated java files is now
passed in the classpath to javac (thanks to Tim Delaney).
- added "_jsp." prefix to generated package name, preventing
collision with existing package names.
- added "_" prefix to each component of the generated package
name to prevent generation of illegal package names (thanks to
Jörn Heid).
- fixed a few (documentation) bugs in HTMLWriter.
- added credits (sorry I forgot last time).
Version 0.9.4 (23 Sep 1998):
- major part of GnuJSP toolkit released.
- fixed bug with backslashes in HTML code (thanks to Martijn van
Berkum).
- compiler errors are now HTML encoded.
Version 0.9.3 (15 Sep 1998):
- fixed bug that prevented POST forms from working (the variable
"BufferedReader in" has been removed).
Version 0.9.2 (12 Sep 1998):
- JRun compatibility (thanks to Hendrik Schreiber and Jörn
Heid).
- added -classpath argument to the javac command line (thanks to
Hendrik Schreiber).
- test for ".jsp" extension.
- MailBean takes multiple To-recipients and Bcc-recipients.
Version 0.9.1 (5 Sep 1998):
- java line number to jsp line number mapping for javac error
messages.
- <BEAN> support (including introspection and
<PARAM> tags).
- JSP example pages.
- developed a bean that can send email messages (MailBean).
- vinclude directive.
- SSI style includes.
- a nice logo (thanks to Erwin Bolwit).
- optional checking of request URI for /servlet/ and
/jsp/.
- changed some parser details. Shouldn't affect well-formed
pages.
- backslashes in filenames are encoded (thanks to Jörn
Heid).
- lots of other small things.
Version 0.9.0 (27 Aug 1998):
Todo
- implement JSP specification 0.92.
- integrate into the Giant Java Tree.
- implement page caching.
- use JavaCC of Antrl to generate the parser.
- add possibility to use other java compiler.
- release rest of GnuJSP toolkit (HTML tokenizer).
Copyright
This software is distributed under the terms of the
GNU Public
License. Please see the file COPYING included with the
distribution for details.