Skip to content
Search

Java Server Pages

lastmod 2022-08-18created 2014-03-115 edits

JavaServer Pages (JSP) is a language that embeds Java code in HTML to generate web pages dynamically on a web server and return them to the web browser. As part of the Java EE specification, it runs on a web application server.

At run time, JavaServer Pages are converted into Java servlets before they run, so they can be considered nearly the same as servlets. However, unlike servlets, they are written according to the HTML standard, which makes web design convenient. Similar technologies include PHP, ASP, and ASP.NET.

When using JSP tag libraries such as Apache Struts or the Jakarta Project's JSTL, pages can be written concisely with tags alone, without Java coding, which improves productivity.

How it works

When a client requests a service, the JSP is asked to run, and the JSP is converted into servlet source code in the servlet container of the web application server. The servlet source code is then compiled immediately and run, and the result is returned to the client as HTML.

Example

<p>Counting to three:</p>
<% for (int i=1; i<4; i++) { %>
    <p>This number is <%= i %>.</p>
<% } %>
<p>OK.</p>

See also

Favorite site

author Zer0 sitemap