JavaServer Pages – JSP
JavaServer Pages (JSP) is a Java technology that allows software developers to create dynamically-generated web sites, with HTML, XML, or other document types, in response to a Web client request. The technology allows Java code and certain pre-defined actions to be embedded into static content.
JSPs are compiled into Java Servlets by a JSP compiler. A JSP compiler may generate a servlet in Java code that is then compiled by the Java compiler, or it may generate byte code for the servlet directly. JSPs can also be interpreted on-the-fly, reducing the time taken to reload changes.
The biggest advantage of using JSP is that it helps effectively separate presentation from content.
A JavaServer Page may be broken down into the following pieces:
* static data such as HTML
* JSP directives such as the include directive
* JSP scripting elements and variables
* JSP actions
* custom tags with correct library.
We can have various:
| Expressions: | Expression is evaluated and placed in output. |
| Scriptlets: | Code is inserted in service method. |
| Declarations: | Code is inserted in body of servlet class, outside of service method. |
| Page directives: | Directions to the servlet engine about general setup. |
| Comments: | Comment; ignored when JSP page is translated into servlet. |
| Include directives: | Includes a file at the time the page is requested. |
| Use beans: | Find or build a Java Bean. |
| Set property: | Set bean properties, either explicitly or by designating that value comes from a request parameter. |
| Get property: | Retrieve and output bean properties. |
| Forward action: | Forwards request to another page. |
and a few more in a JSPage.
The layouts below describe the Model 1 and MOdel2 JSP architectures.

In Model 1, the JSP page alone is responsible for processing the incoming request and replying back to the client. There is still separation of presentation from content, because all data access is performed using beans.

The Model 2 architecture, is a hybrid approach for serving dynamic content.It combines the use of both servlets and JSPs. It takes advantage of using JSP to generate the presentation layer and servlets to perform process-intensive tasks. Here, the servlet acts as the controller and is in charge of the request processing and the creation of any beans or objects used by the JSP, as well as deciding, depending on the user’s actions, which JSP page to forward the request to.
To read about the Java Application Architecture, IDE’s, application frameworks -
Click here
To read about a few of the general application frameworks available -
Read here

