Within the scope of implementing my own webserver in Java I want to support JSPs. For the moment I don't want to write a JSP engine myself but use an existing one.
I found several JSP engines (e.g. Jasper
or Jakarta
) but they all come within their own webservers.
Is there a JSP engine implementation that is available as a standalone library?
-
2Why? JSP is only defined to run inside a Servlet container. You've got a large task in front of you if you're reimplementing Tomcat, or Glassfish, or JBoss. – user207421 Feb 17 '14 at 09:35
-
1thats why I am searching for a standalone library – Markus Feb 17 '14 at 09:46
4 Answers
This will be a very difficult task. You will lose the benefit of runtime compilation, hot deploy, mapping, jsp precompilation / caching and probably much more.
Outlooking these facts, you can always compile your JSPs with some of the tools that are already provided by the app server.
Here is a short sample :
- Apache Jasper, you can download from maven the standalone api from here and have a look at the javadoc here.
- Weblogic jspc : here
- You own parser ???
Ant has bundled a bunch of optional tasks that you could call to [pre]compile your jsps :
Then call ant from your server logic (Is it possible to call Ant or NSIS scripts from Java code?) or precompile your JSPs when you build your server.
Also, if it's all about creating a web container then why not just write plain and simple servlets.
You can take jastow, which is fork of jasper (from tomcat) to be easier fitted into clean servlet implementation.
It was done to add support for JSP to undertow servlet implementation.

- 5,761
- 25
- 32
You can take a look at GNUJSP , but the project is not active i guess.

- 11,287
- 3
- 29
- 38
In some projects JSPs are precompiled, so there are ant and maven builds integrating a JSP compiler.
- Maven: JspC
I would work on the basis of that, as it is in active use. Inspect the generated java or jvm byte code (javap) to provide (too) specific implementation classes.

- 107,315
- 7
- 83
- 138