What is JSP? Introduction to JavaServer Pages

One of the original Java web technologies, JavaServer Pages is still widely used to build dynamic web pages that connect to the Java backend

1 2 Page 2
Page 2 of 2

Layout of a JSP web application

Tomcat follows the standard layout for Java servlet and JSP pages. The general structure is a folder with the name of the application, which is deployed inside Tomcat's /webapps directory.

In the Implicit Objects app, the application is /examples. Opening that folder reveals three important children: the /WEB-INF directory, the index.html file, and a set of other directories.

The WEB-INF directory contains metadata that informs Tomcat how to run the app.

The rest of the content, including index.html, is directly accessible, just like it would be in a typical web server. Likewise, the implicit-objects.jsp is available to view, and is automatically handled as a JSP page (not an HTML page) by the server.

Request-response architecture

In a typical servlets/JSP application, servlets receive requests and interact with server-side components and services (such as the database) to fulfill them. Once handled, the request result is forwarded to a JSP page, which presents the response.

A servlet uses the following syntax when sending a request response to a JSP page:


Whatever data the servlet has inserted into the various JSP scopes will be accessible to JSP. A scope is simply a range of life for a given object. Request and response objects are request scoped, meaning they live for the duration of the request. Other scopes include page scope (living as long as the JSP page does) and session scope (terminating when the user ends the given session).


JavaServer Pages is a well known and versatile technology for developing Java web application views. Combined with servlets, JSP pages are very powerful, and provide access to the entire range of Java capabilities. While JSP may not be your first choice for developing a modern Java web application, you will encounter JSP pages in legacy applications. It's also a good choice for simpler applications, where you want to quickly connect your HTML frontend to server-side Java code. The JSTL tags are capable of handling most web application requirements, and third-party libraries extend that functionality for specific technologies and use cases.

This story, "What is JSP? Introduction to JavaServer Pages" was originally published by JavaWorld.

Copyright © 2019 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2
How to choose a low-code development platform