Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP engines without webserver

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?

like image 913
Markus Avatar asked Feb 14 '14 12:02

Markus


People also ask

How is JSP page loaded?

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.

How does the JSP processing takes place?

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.

What are the different types of JSP Architecture explain?

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.

What is JSP container?

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.


1 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 :

  • Weblogic Compilation task
  • Japser Compilation task

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.

like image 117
Laurent B Avatar answered Sep 28 '22 13:09

Laurent B