Java Server Pages
(https://en.wikipedia.org/wiki/JavaServer_Pages)
JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun Microsystems, JSP is similar to PHP and ASP, but it uses the Java programming language.
To deploy and run JavaServer Pages, a compatible web server with a servlet container, such as Apache Tomcat or Jetty, is required.
JavaServer Pages Overview
(http://www.oracle.com/technetwork/java/overview-138580.html)
– | Benefits for Developers |
– | JSP Technology and Java Servlets |
– | Community Background |
If you are a Web page developer or designer who is familiar with HTML, you can:
- Use JSP technology without having to learn the Java language: You can use JSP technology without learning how to write Java scriplets. Although scriptlets are no longer required to generate dynamic content, they are still supported to provide backward compatibility.
- Extend the JSP language: Java tag library developers and designers can extend the JSP language with “simple tag handlers,” which utilize a new, much simpler and cleaner, tag extension API. This spurs the growing number of pluggable, reusable tag libraries available, which in turn reduces the amount of code needed to write powerful Web applications.
- Easily write and maintain pages: The JavaServer Pages Standard Tag Library (JSTL) expression language is now integrated into JSP technology and has been upgraded to support functions. The expression language can now be used instead of scriptlet expressions.
JSP technology uses XML-like tags that encapsulate the logic that generates the content for the page. The application logic can reside in server-based resources (such as JavaBeans component architecture) that the page accesses with these tags. Any and all formatting (HTML or XML) tags are passed directly back to the response page. By separating the page logic from its design and display and supporting a reusable component-based design, JSP technology makes it faster and easier than ever to build Web-based applications.
JavaServer Pages technology is an extension of the Java Servlet technology. Servlets are platform-independent, server-side modules that fit seamlessly into a Web server framework and can be used to extend the capabilities of a Web server with minimal overhead, maintenance, and support. Unlike other scripting languages, servlets involve no platform-specific consideration or modifications; they are application components that are downloaded, on demand, to the part of the system that needs them. Together, JSP technology and servlets provide an attractive alternative to other types of dynamic Web scripting/programming by offering: platform independence; enhanced performance; separation of logic from display; ease of administration; extensibility into the enterprise; and, most importantly, ease of use.
Today servlets are a popular choice for building interactive Web applications. Third-party servlet containers are available for Apache Web Server, Microsoft IIS, and others. Servlet containers are usually a component of Web and application servers, such as BEA WebLogic Application Server, IBM WebSphere, Sun Java System Web Server, Sun Java System Application Server, and others.
Chapter 5 – JavaServer Pages Technology – The Java EE 5 Tutorial
(https://docs.oracle.com/javaee/5/tutorial/doc/bnagx.html)
JavaServer Pages (JSP) technology allows you to easily create web content that has both static and dynamic components. JSP technology makes available all the dynamic capabilities of Java Servlet technology but provides a more natural approach to creating static content.
The main features of JSP technology are as follows:
- A language for developing JSP pages, which are text-based documents that describe how to process a request and construct a response
- An expression language for accessing server-side objects
- Mechanisms for defining extensions to the JSP language
JSP technology also contains an API that is used by developers of web containers, but this API is not covered in this tutorial.
JSP Tutorial for Beginners with Examples – Java Server Pages
(http://beginnersbook.com/jsp-tutorial-for-beginners/)
Java Server Pages (JSP) is a server side technology for developing dynamic web pages. This is mainly used for implementing presentation layer (GUI Part) of an application. A complete JSP code is more like a HTML with bits of java code in it. JSP is an extension of servlets and every JSP page first gets converted into servlet by JSP container before processing the client’s request.
Below are the links of tutorial shared on JSP. If you are beginner then read them in the given sequence to understand the technology in a better way.
Overview
Elements of JSP
Directives
JSP directives are used for controlling the processing of a JSP page. Directives provide information to the server on how the page should be processed.
- Page and Taglib directive – Page directive and it’s attributes in detail along with the introduction of taglib directive.
- Include Directive – Includes the page to the current page during JSP to servlet translation.
- Include directive with parameters – This guide will help you learn how to pass parameters and their values to another page while using include directive.
Scriptlets
We can use java code in JSP using scriptlets. The JSP container moves the scipetlet content into the _jspService() method which is available to the server during processing of the request.
Scriptlet tutorial – It will help you learn how to use scriptlet in JSP.
Action Tags
They are used for performing an action during request processing phase of JSP life cycle.
- Action tags introduction – An introduction to all the available action tags in JSP
- Include action tag – This tag is used for including a file to the current JSP during request processing (dynamically).
- Include action tag with parameters – <jsp:include> and <jsp:param> example for passing parameters while including another page to the current page.
- forward action tag – It is used for redirecting the request to another page.
- useBean, setProperty and getProperty action tags – Learn how to use bean class in JSP.
Expressions
Expression tag – Mainly used for displaying the content on the browser by sending back the result to client through response object.
Declarations
Declaration tag – Learn how to declare variables and methods in JSP.
JSP Implicit Objects
These objects are created by JSP container while translating the JSP page to Servlet. These objects are present inside service methods so we can directly use them without declaration.
- Introduction to implicit objects
- out implicit object
- request implicit object
- response implicit object
- session implicit object
- application implicit object
- exception implicit object
- pageContext implicit object
- config implicit object
Expression language(EL) in JSP
Expression language(EL) – We can easily access the data of variables, bean components and expressions using Expression language. Must read tutorial for JSP beginners.
Exception handling
Exception handling in JSP – A complete tutorial to learn exception handling in JSP. We have shared two methods to handle exceptions.
Custom Tags