Java Server Pages
JSP is a Java technology that helps software developers serve dynamically
generated web pages based on HTML, XML, or other document types,
developed by Sun.
With JSP you can create dynamic web pages by putting Java code inside
your HTML pages. The code is executed by the web server before the page
is returned to the browser.
Since JSP uses Java, the technology is not restricted to any server-specific
This technology provides a simplified, fast way to create dynamic web
content. JSP technology enables rapid development of web-based
applications that are server-independent and platform-independent.
The JSP Standard Tag Library (JSTL) is a collection of tag libraries that
implement general-purpose functionality common to many Web applications.
JSP may be viewed as a high-level abstraction of Java servlets. JSP pages
are loaded in the server and operated from a structured special installed
Java server packet called a Java EE Web Application, often packaged as a
.war or .ear file archive.
JSP allows Java code and certain pre-defined actions to be interleaved with
static web markup content, with the resulting page being compiled and
executed on the server to deliver an HTML or XML document
JSP syntax is a fluid mix of two basic content forms: scriptlet elements and
Java code is not required to be complete (self contained) within its scriptlet
element block, but can straddle markup content providing the page as a
whole is syntactically correct.
The JSP syntax adds additional XML-like tags, called JSP actions, to invoke
built-in functionality. Additionally, the technology allows for the creation of
JSP tag libraries that act as extensions to the standard HTML or XML tags.
Java Virtual Machine (JVM) operated tag libraries provide a platform
independent way of extending the capabilities of a web server.
Usage of JSP:
JSP is widely used for developing dynamic web sites.
JSP is used for creating database driven web applications because it
provides superior server side scripting support.
Some of the reasons for the popularity of JSP:
Simplifies the process of development.
Independency of Layers.
Simplification of Process.
Steps for Setting JSP Environment:
The Java Server Page or JSP is very affordable as most of the software
needed for it is easily available for free or at low cost.
The Java Developer Kit which is available for free
The Tomcat web server if used is available for free.
HTML editor would be needed to purchase.
Tags are a vital concept in Java Server Pages (JSP). Below is a list of tags
used in JSP.
List of the tags used in Java Server Pages:
Declaration tag is used to define functions, methods and variables that will
be used in Java Server Pages.
Notation of the Declaration tag is shown below:
private int example = 0 ;
private int test = 5 ;
Expression tag is used to display output of any data on the generated page.
The data placed in Expression tag prints on the output stream and automatically
converts data into string. The Expression tag can contain any Java expression used
for printing output equivalent to out.println().Thus, an expression tag contains a
scripting language expression which is evaluated, automatically converts data to a
String and the outputs are displayed.
Notation of Expression tag is shown below:
Exfdate: <%= new java.util.Date() %>
JSP is a high-end technology that helps developers insert java code in HTML
pages by making use of special JSP tags.
The JSP are HTML pages but do not automatically have .html as file
extension. JSP files have .jsp as extension. The following step takes place in
execution of a JSP file.
JSP files are compiled by JSP engine into a servlet. This step creates the
.jsp file as a Java servlet source file.
Once this is processed, the source file above is compiled into a class file.
The engine then makes use of the compiled servlet from the above process
and executes requests.
Out of the two processes, the first two take time to produce a compiled
servlet. This is performed only once unless modification in the source file is
Once the compiled servlet is completed, the execution of requests is
performed at a faster speed.
There are two methods for using JSP technology:
Advantages of JSP:
vs. Active Server Pages (ASP). ASP is a similar technology from Microsoft.
The advantages of JSP are twofold. First, the dynamic part is written in
Java, not Visual Basic or other MS-specific language, so it is more powerful
and easier to use. Second, it is portable to other operating systems and non-
Microsoft Web servers.
vs. Pure Servlets. JSP doesn't give you anything that you couldn't in
principle do with a servlet. But it is more convenient to write (and to modify!)
regular HTML than to have a zillion println statements that generate the
HTML. Plus, by separating the look from the content you can put different
people on different tasks: your Web page design experts can build the
HTML, leaving places for your servlet programmers to insert the dynamic
vs. Server-Side Includes (SSI). SSI is a widely-supported technology for
including externally-defined pieces into a static Web page. JSP is better
because it lets you use servlets instead of a separate program to generate
that dynamic part. Besides, SSI is really only intended for simple inclusions,
not for "real" programs that use form data, make database connections, and
This is a useful capability, but only handles situations where the dynamic
information is based on the client's environment. With the exception of
like databases, catalogs, pricing information, and the like.
vs. Static HTML. Regular HTML, of course, cannot contain dynamic
information. JSP is so easy and convenient that it is quite feasible to
augment HTML pages that only benefit marginally by the insertion of small
amounts of dynamic data. Previously, the cost of using dynamic data would
preclude its use in all but the most valuable instances.