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?
The JSP engine loads the JSP page from disk and converts it into a servlet content. This conversion is very simple in which all template text is converted to println( ) statements and all JSP elements are converted to Java code. This code implements the corresponding dynamic behavior of the page.
The JSP engine compiles the servlet into an executable class and forwards the original request to a servlet engine. A part of the web server called the servlet engine loads the Servlet class and executes it. During execution, the servlet produces an output in HTML format.
JSP architecture is a 3 tier architecture. It has a Client, Web Server, and Database. The client is the web browser or application on the user side. Web Server uses a JSP Engine i.e; a container that processes JSP.
A JSP container is an entity that translates, executes, and processes JSP pages and delivers requests to them. The exact make-up of a JSP container varies from implementation to implementation, but it will consist of a servlet or collection of servlets. The JSP container, therefore, is executed by a servlet container.
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 :
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With