0% found this document useful (0 votes)
30 views

Spring MVC Introduction To Javaee: Yet Another Web Framework Enter Enterprise Java

Uploaded by

Almog Goldberg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Spring MVC Introduction To Javaee: Yet Another Web Framework Enter Enterprise Java

Uploaded by

Almog Goldberg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Spring MVC to JavaEE

Introduction
Yet Another
Enter Enterprise
Web Java
Framework

copyright 2009 Trainologic LTD


Spring MVC –to
Introduction part
JavaEE
1

• Introduction
The Need for JavaEE
• Overview
The MVC Pattern
on the JavaEE Architecture
• JavaEE
Spring MVC
Key Standards
Implementation
• Controllers
• Mapping Request Handlers
• Views
• I18N and Locale Resolvers
• Customizing Look & Feel using Themes
• File Uploading
• Error Handling
• Using Annotations copyright 2009 Trainologic LTD
Introduction to JavaEE

The Need for JavaEE

• JavaSE is a great tool to write all sorts of applications.


• However, enterprise applications’ development using
JavaSE is cumbersome at best and not even feasible in
the worst case.
• JavaEE targets enterprise applications’ development and
greatly eases the process.

3
copyright 2009 Trainologic LTD
Introduction to JavaEE

What is JavaEE?

• JavaEE is a specification.
• It is actually an umbrella of many specifications that
provide different services to enterprise applications.

• These specifications have two faces:


• An API that enterprise applications can use.
• An API that the Application Server must implement.

• Wait a sec, what is an Application Server anyway?

4
copyright 2009 Trainologic LTD
Introduction to JavaEE

The Application Server

• Enterprise applications that use JavaEE are usually


deployed on an Application Server.
• The Application Server supports some (or all) of the
JavaEE standards.
• There are many Application Servers in the market, the
most popular are:

• WebSphere (by IBM).


• WebLogic (Oracle – former BEA).
• JBossAS (Redhat – former JBoss).

5
copyright 2009 Trainologic LTD
Introduction to JavaEE

The Supplied Services

• The JavaEE umbrella defines a number of sub-


specifications that provide many services.
• Some examples:
• Web development – Servlets/ JSP/ JSF.
• Transactions – JTA / JTS.
• Naming – JNDI.
• Web Services – JAX-WS.
• Enterprise business logic layer – EJB.

6
copyright 2009 Trainologic LTD
Introduction to JavaEE

• The Need for JavaEE


• Overview on the JavaEE Architecture
• JavaEE Key Standards

copyright 2009 Trainologic LTD


Introduction to JavaEE

JavaEE Tiers

8
copyright 2009 Trainologic LTD
Introduction to JavaEE

JavaEE Architecture

9
copyright 2009 Trainologic LTD
Introduction to JavaEE

• The Need for JavaEE


• Overview on the JavaEE Architecture
• JavaEE Key Standards

copyright 2009 Trainologic LTD


Introduction to JavaEE

JavaEE Key Standards

• The key standards of JavaEE are:


• Servlets / JSP / JSF.
• JNDI.
• JTA.
• JAX-WS.
• JCA.
• JavaMail.
• JMS.

11
copyright 2009 Trainologic LTD
Introduction to JavaEE

Servlets, JSP and JSF

• Servlets, JSP and JSF standards pertain to the Web Tier.


• Servlets are Java classes that can handle HTTP requests
and produce HTTP responses.

• Servlets are the building blocks of every JavaEE web


application.
• Note that JSP & JSF standards are based on Servlets.

12
copyright 2009 Trainologic LTD
Introduction to JavaEE

Servlet

• It is important to understand that the Servlets model


specifies that only one instance exists per Servlet.
• Hence, concurrent requests to the same Servlet will be
handled by the same instance.

• Did anyone say ‘resource management’?

13
copyright 2009 Trainologic LTD
Introduction to JavaEE

JSP

• JSP stands for Java Server Pages.


• JSP is a view technology.
• Although Servlets can be used for generating the
presentation itself, it is not recommended to do so.
• JSP is a template technology in which there is a mix
between template data (HTML & Javascript) and Java
code.
• Let’s see an example…

14
copyright 2009 Trainologic LTD
Introduction to JavaEE

JSP Example

• Here is an example of a simple JSP:


<HTML>
<BODY>
<%
// This scriptlet declares and initializes "date"
System.out.println("Evaluating the current date");
java.util.Date date = new java.util.Date();
%>
Hello! The time is:
<%
out.println(date);
out.println("<BR>Your machine's address is: ");
out.println(request.getRemoteHost());
%>
</BODY>
</HTML>

15
copyright 2009 Trainologic LTD
Introduction to JavaEE

JSF

• JSF stands for Java Server Faces.


• JSF is a web development framework which is
component-based.

• In JSF the page is constructed from a tree of


components.
• JSF defines a life-cycle, event system and API for these
components.
• Many JSF component libraries can be found on the web.

16
copyright 2009 Trainologic LTD
Introduction to JavaEE

JNDI

• JNDI stands for Java Naming & Directory Interface.


• A Naming Service stores objects by their names.
• A Directory Service stores objects by name and also
associates attributes to them.
• The JNDI standard provides a uniform naming &
directory API which is vendor independent.

• Just like JDBC with relational databases.

17
copyright 2009 Trainologic LTD
Introduction to JavaEE

JNDI Examples

• Here are some examples of providers that have a JNDI


‘driver’:
• Windows Registry.
• The file system.
• DNS (Domain Name System).
• COS (Common Object Services) – CORBA naming
server.
• LDAP.
• RMI Registry.
18
copyright 2009 Trainologic LTD
Introduction to JavaEE

The JNDI Architecture

• The JNDI organizes the objects in a tree structure.


• Each node in the tree is called Context.
• A context can have sub-contexts or objects-names
mappings.
• We’ll see how to use the JNDI API in later chapters.

19
copyright 2009 Trainologic LTD
Introduction to JavaEE

JTA/JTS

• Java Transaction API (JTA) and Java Transaction Service


(JTS) provide distributed transaction services for JavaEE
applications.

• Transaction management is very important and one of


the key factors in the success of the EJB standard.
• We’ll discuss transactions in a later chapter.

20
copyright 2009 Trainologic LTD
Introduction to JavaEE

JAX-WS

• JAX-WS stands for Java API for XML – Web Services.


• It allows to easily expose POJOs as Web Services.
• Here is an example of a Web Service:
import javax.jws.WebService;

@WebService
public class HelloWorld {
public String sayHello() {
return "Hello World";
}
}

21
copyright 2009 Trainologic LTD
Introduction to JavaEE

JCA

• JCA stands for J2EE Connector Architecture.


• JCA provides a way to incorporate legacy applications
into the management of the Application Server.

• The Application Server knows all about transaction


management, resource pooling and security.
• So, when integrating with a legacy system, why do we
need to re-invent the wheel (handle connections,
transactions and security for the legacy system)?

22
copyright 2009 Trainologic LTD
Introduction to JavaEE

JCA

• By writing a special driver (called a Resource Adapter),


you can have the Application Server handle connections,
transactions and security for your legacy system.

• JCA also supports incoming transactions, work


management and has a special connection to Message
Driven Beans.

23
copyright 2009 Trainologic LTD
Introduction to JavaEE

JavaMail

• JavaMail provides a vendor and protocol independent


framework to handle mail and messaging applications.
• With JavaMail you can receive and send e-mails using
POP3, IMAP and SMTP.

24
copyright 2009 Trainologic LTD
Introduction to JavaEE

JMS

• Java Message Service provides a uniform vendor-


independent API for messaging systems.
• A messaging system provides asynchronous and reliable
messaging.
• JMS supports both Peer-to-Peer and Publish/Subscribe
modes.

• We’ll discuss JMS in details in the Message Driven Bean


chapter.

25
copyright 2009 Trainologic LTD
Introduction to JavaEE

EJB

• Hey, didn’t we forget one of the most important


specifications?
• What about EJBs?

• Well, from now on, we’ll discuss nothing else…

26
copyright 2009 Trainologic LTD

You might also like