ge_title -->

Plateform for Enterprise Solution: Java EE5

Plateform for Enterprise Solution: Java EE5

  • The Java EE platform is a set of standard specifications that describe application components, APIs, and the runtime containers and services of an application server.
  • Java Platform, Enterprise Edition (Java EE) is the standard in community-driven enterprise software.
  • Java EE is developed using the Java Community Process, with contributions from industry experts, commercial and open source organizations, Java User Groups, and countless individuals.
  • Each release integrates new features that align with industry needs, improves application portability, and increases developer productivity.
  • Today, Java EE offers a rich enterprise software platform,  and with over 20 compliant Java EE  implementations to choose from, low risk and plenty of options.

What’s New

  • As the industry begins the rapid adoption of Java EE 7, work has begun on Java EE 8.  With a survey that received over 4,500 responses, the community has prioritized the desired features for Java EE 8.
    • JSR 366 – Java EE 8
    • JSR 367 – The Java API for JSON Binding
    • JSR 368 – Java Message Service 2.1
    • JSR 369 – Java Servlet 4.0 uJSR 370 – Java API for RESTful Web Services 2.1
    • JSR 371 – Model-View-Controller 1.0
    • JSR 372 – Java Server Faces 2.3
    • JSR 373 – Java EE Management API 1.0
    • JSR 374 – Java API for JSON Processing 1.1
    • JSR 375 – Java EE Security API 1.0

Web core technologies: Servlets and JSP

  • What is the difference between JSF, Servlet and JSP ?
    • Servlet is html in java
    • JSP is java in html
 Web core technologies: Servlets and JSP
Web core technologies: Servlets and JSP

Java Server Faces (JSF)

  • Java Server Faces (JSF) is a Java-based web application framework intended to simplify development integration of web-based user interfaces.
  • Java Server Faces is a standardized display technology which was formalized in a specification through the Java Community Process.

What is JSF?

  • JSF is a MVC web framework that simplifies the construction of user interfaces (UI) for server-based applications by using reusable UI components in a page.
  • JSF provides facility to connect UI widgets with data sources and to server-side event handlers.
  • The JSF specification defines a set of standard UI components and provides an Application Programming Interface (API) for developing components.
  • JSF enables the reuse and extension of the existing standard UI components.

JSF Benefits

  • Providing reusable UI components
  • Making easy data transfer between UI components
  • Managing UI state across multiple server requests
  • Enabling implementation of custom components
  • Wiring client side event to server side application code

JSF UI component model

  • Core library
  • A set of base UI components – standard HTML input elements
  • Extension of the base UI components to create additional UI component libraries or to extend existing components.
  • Multiple rendering capabilities that enable JSF UI components to render themselves differently depending on the client types

What is MVC Design Pattern?

Module Description
Model Carries Data and login
View Shows User Interface
Controller Handles processing of an application

JSF Architecture

JSF Architecture
JSF Architecture

JSF – Life Cycle

JSF - Life Cycle
JSF – Life Cycle

Servlets

  • Servlets provide a component-based, platform-independent method for building Web-based applications, without the performance limitations of CGI programs.
  • Servlets have access to the entire family of Java APIs, including the JDBC API to access enterprise databases.

What are Servlets?

  • Java Servlets are programs that run on a Web or Application server and act as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server.
  • Using Servlets, we can collect input from users through web page forms, present records from a database or another source, and create web pages dynamically.

Servlets advantages in comparison with the CGI

  • Performance is significantly better.
  • Servlets execute within the address space of a Web server. It is not necessary to create a separate process to handle each client request.
  • Servlets are platform-independent because they are written in Java.
  • Java security manager on the server enforces a set of restrictions to protect the resources on a server machine. So servlets are trusted.
  • The full functionality of the Java class libraries is available to a servlet. It can communicate with applets, databases, or other software via the sockets and RMI mechanisms that you have seen already.

Servlets Architecture

Servlets Architecture
Servlets Architecture

Servlets Tasks

  • Read the explicit data sent by the clients (browsers). This includes an HTML form on a Web page or it could also come from an applet or a custom HTTP client program.
  • Read the implicit HTTP request data sent by the clients (browsers). This includes cookies, media types and compression schemes the browser understands, and so forth.
  • Process the data and generate the results. This process may require talking to a database, executing an RMI or CORBA call, invoking a Web service, or computing the response directly.
  • Send the explicit data (i.e., the document) to the clients (browsers). This document can be sent in a variety of formats, including text (HTML or XML), binary (GIF images), Excel, etc.
  • Send the implicit HTTP response to the clients (browsers). This includes telling the browsers or other clients what type of document is being returned (e.g., HTML), setting cookies and caching parameters, and other such tasks.

Servlets Packages

  • Java Servlets are Java classes run by a web server that has an interpreter that supports the Java Servlet specification.
  • Servlets can be created using the javax.servlet and javax.servlet.http packages, which are a standard part of the Java’s enterprise edition, an expanded version of the Java class library that supports large-scale development projects.

Related Posts:

Servlet Development environment setup

Setting up Java Development Kit

  • It is initialized by calling the init () method.
  • It calls service() method to process a client’s request.
  • It is terminated by calling the destroy() method.
  • Finally, it is garbage collected by the garbage collector of the JVM.

Architecture Diagram

Architecture Diagram
Architecture Diagram

Servlets

  • Form Data
  • Client Request
  • Server Response
  • Http Codes
  • Writing Filters
  • Exceptions
  • Cookies Handling
  • Session Tracking
  • Database Access
  • File Uploading
  • Handling Date
  • Page Redirect
  • Hits Counter
  • Auto Refresh
  • Sending Email
  • Packaging
  • Debugging
  • Internationalization

JSP

  • Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications.
  • JSP have access to the entire family of Java APIs, including the JDBC API to access enterprise databases.

What is Java Server Pages?

  • Java Server Pages (JSP) is a technology for developing web pages that support dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>.
  • A Java Server Pages component is a type of Java servlet that is designed to fulfill the role of a user interface for a Java web application.

Why Use JSP?

  • Performance is significantly better because JSP allows embedding Dynamic Elements in HTML Pages itself instead of having a separate CGI files.
  • JSP are always compiled before it’s processed by the server unlike CGI/Perl which requires the server to load an interpreter and the target script each time the page is requested.
  • Java Server Pages are built on top of the Java Servlets API, so like Servlets, JSP also has access to all the powerful Enterprise Java APIs, including JDBC, JNDI, EJB, JAXP etc.
  • JSP pages can be used in combination with servlets that handle the business logic, the model supported by Java servlet template engines.

Advantages of JSP

  • vs. Active Server Pages (ASP): 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: It is more convenient to write (and to modify!) regular HTML than to have plenty of println statements that generate the HTML.
  • vs. Server-Side Includes (SSI): SSI is really only intended for simple inclusions, not for “real” programs that use form data, make database connections, and the like.
  • vs. JavaScript: JavaScript can generate HTML dynamically on the client but can hardly interact with the web server to perform complex tasks like database access and image processing etc. uvs. Static HTML: Regular HTML, of course, cannot contain dynamic information.

JSP – Architecture

 JSP - Architecture
JSP – Architecture

JSP Processing

JSP Processing
JSP Processing

JSP – Life Cycle

  • Compilation
  • Initialization
  • Execution
  • Cleanup

JSP – Life Cycle

 JSP - Life Cycle
JSP – Life Cycle

JSP Compilation

  • The compilation process involves three steps:
    • Parsing the JSP.
    • Turning the JSP into a servlet.
    • Compiling the servlet.

JSF, Servlet and JSP

  • JSP is a webpage scripting language that can generate dynamic content while Servlets are Java programs that are already compiled which also creates dynamic web content
  • Servlets run faster compared to JSP
  • JSP can be compiled into Java Servlets
  • It’s easier to code in JSP than in Java Servlets
  • In MVC, JSP act as a view and servlet act as a controller.
  • JSP are generally preferred when there is not much processing of data required. But servlets are best for use when there is more processing and manipulation involved.
  • The advantage of JSP programming over servlets is that we can build custom tags which can directly call Java beans. There is no such facility in servlets.
  • We can achieve functionality of JSP at client side by running JavaScript at client side. There are no such methods for servlets.

Read Also:

1 thought on “Plateform for Enterprise Solution: Java EE5”

Leave a Comment