You are on page 1of 50

Design and Implementation of

the View:
Servlets and JSP™

1
Agenda

• What are Servlets?


• What are JSP™ s?
• Designing Issues
• Architecting the "View" or
Presentation logic

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

2
The History of Dynamic Content
Creation on the Internet.

• Common Gateway • Servlets


Interface – Java running on the
– Platform dependant server
– Resource Intensive – Portable
– Server vendors – Performing &
have enhanced CGI scalable.
for their specific – connection pooling.
products.
– Session
– Content and logic management.
used to display the
content is combined – Content and logic
used to display the
content is combined.

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Lets turn to the real world to understand the business need for JSP.
HTTP – a request response protocol, stateless.
The internet initially provided static content.
Programmers needed a hook into the web server to dynamically modify requests.
Common Gateway Interface:
- access resources (file system and database)
- not good for a distributed environment.
- a separate process is needed for every request – does not scale well.
Servlets:
- Platform and web server dependant.
- Can use Java APIs to access enterprise resources.
- Build on existing skills.
- Servlets can be loaded into memory and reused.
- Requests use only one light weight thread.
- Servlet context allows pooling of enterprise resources.
- Session API used to overcome the limitations of the stateless HTTP protocol.

3
What Are Servlets?
Servlets are Java’s answer to CGI/Perl...
§ Server side Java™ program that extends the
functionality of a HTTP Web Server,
…respond to web server requests
§ Used to generate dynamic HTML Browser
Applications
§ Alternative for CGI, NSAPI, ISAPI, etc.
§ Available and running on all major web servers
§ Platform and Web Server Independent
§ Simple architecture
§ Managed by container
§ Very rich platform facilities available
© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Although http is a standard protocol, each browser has it’s own oddities. It’s a webmaster’s
nightmare to deal with this. Typically, instead of a static set of html pages, pages are generated
on the fly for browser specific customization.

Also, in several situations it may be necessary to serve a page which is based on a template
and some entries filled in dynamically.

Different alternatives exist. You may use webserver extensions like NSAPI,
ISAPI, Apache modules, etc. However, these work only with that respective webserver and
will be difficult to migrate to a different webserver in the future. CGI is a cross platform and
cross server way of solving the problem but CGI has many performance issues.

Servlets and JSP™ is a superior alternative. They are available on almost all webservers and
they open up the “Java world” to the webservers.

4
Why Servlets?

• HTTP Internet protocol make applications


available everywhere
• Server independent, Superior alternative to
proprietary HTTP server APIs
• Easy to program
• Written in pure Java
– Platform independent
– Can take advantage of JDBC, EJB, JMS, JavaMail,
JavaIDL, RMI, APIs...
• Scalability, uses Lightweight threads:
– Don’t start new process for each request
– Threads can be cached
– Can run in same server process as HTTP server
– Multi-threaded
© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Read the slide and emphasize the points

5
Servlets and JSP™s Run in Web Container

Applet Web Container EJB Container


Container
Applet HTTP/ JSP Servlet RMI EJB
HTTPS

J2SE

RMI/IIOP

RMI/IIOP

JDBC
JDBC
JavaMail JavaMail

JNDI

JMS

JNDI
JTA

JMS

JTA
App Client
Container JAF JAF
App HTTP/
Client HTTPS
J2SE
RMI
RMI/IIOP

JDBC
JNDI
JMS

J2SE J2SE

Database

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

6
Servlets vs. CGI

Request CGI1
Child for CGI1

Request CGI2
CGI
Based Child for CGI2
Webserver
Request CGI1
Child for CGI1

Request Servlet1
Servlet Based Webserver

Request Servlet2 Servlet1


JVM
Request Servlet1 Servlet2

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Servlets are more efficient than CGI.

Notice in the illustration that although the same page was referenced again, a
new process was created to handle the request since that’s the inherent way it’s
done using CGI. Process creation as we all understand is very expensive. In
the servlet model a new thread is created , which is lightweight.
With CGI you make a connection/disconnection for every request. Every
connection is handled by a newly created process.
With Servlets the connections persist and there is no overhead of starting a
new process.

7
Servlet Basics

• Well-defined lifecycle

• Managed by container
• Loaded on demand
• Unloaded by container at any time
• Multi-threaded

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Servlets are often referred to as faceless applets i.e. they do not have a GUI,
but have a well defined lifecycle just like an applet.

8
Servlet Classes

javax.servlet Servlet interface


package
implements
GenericServlet
extends

HttpServlet
extends

HelloWorldServlet Your Servlet

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

9
Illustration of client Request

Server

Session

Request
init()
service()
destroy()
Response

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

10
The Servlet Lifecycle

• Servlet is instantiated by the container

• It is initialized via the init() method

• The service() method is called 0-n


times when a client makes a request

• Can clean up when being unloaded via


the destroy() method

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

This illustrates the lifecycle of the servlet.

The destroy() method may be called on the servlet prior to server shutdown. It
should not be assumed that the servlet is destroyed only on server shutdown
although that’s typically what happens.

11
Request, Response Objects

Server

Request

Servlet

Response

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Request Object:
Encapsulates all information from the client
Provides access to
request headers
InputStream or Reader containing data from the client
CGI Like information
form data and query parameters
server specific parameters such as SSL information
Response Object:
Encapsulates all communication back to the client
Provides access to
response headers
OutputStream to write data to the client
setting cookies
Convenience method for sending redirects, error pages, etc.

12
Request and Response Parameters

•Request
•HTTP request headers

•InputStream or reader

•Input parameters: Form data, cgi data

•Response
•HTTP response headers

•OutputStream or writer

•Setting cookies, redirects, error pages


© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

13
Anatomy of a Request

• A client makes a request on a server


• The request is resolved to a servlet
by the container

• The servlet’s service() method is


invoked with a Request and
Response object
• The servlet provides a response
to the request

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

This is akin to the HTTP request-response model

14
Code for a Simple Servlet

public class ExampleServlet extends HttpServlet {


public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType(“text/html”);
PrintWriter out = request.getWriter();
out.println(“Hello!<BR>”);
}
}

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

15
What is JSP?

• JSP™ turns servlets inside out


– Java code embedded in a HTML page
– A textual document describing how to
create a response from a request
• Template data (HTML, XML)
• Dynamic content
– JSP™ is compiled into a servlet by the
server

– JSP™ is a scripting language framework


– JSP™ is for formatting output such as
HTML
and XML © Copyright 2000 Sun Microsystems, Inc., All rights reserved.

The problem with servlets is that too much of HTML code is embedded in a
Java program violating the cardinal rule of keeping program logic and
presentation separate.

What JSPs do is overcome this problem. The JSP™ contains all the
presentation and only some logic. Most of the program logic is tucked away in
the programs which are invoked by it.

Whereas Servlets have HTML code in Java, JSP™ has Java code in HTML.

16
How do JSP™s Work?

• Written as HTML with JSP™ elements


and template data
• Compiled into HTTP servlet on first call
• Runs with a Java process (JSP™
engine)
• Returns the page to the calling client

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

A declarative presentation-centric method of developing servlets.


Content and display logic are separated.
A mapping between HTML and java beans.
JSP™ pages are compiled into servlets.
When a designer changes a JSP™ page, the page is automatically
recompiled and reloaded in the web server on the next request.
Servlets imbed HTML output into Java programming.
- JSP™ imbeds java programming into HTML – Power & flexibility to content
designers.
- The JSP™ page is then automatically compiled into a servlet to serve
requests for that page.
- Changes to the JSP™ page cause the page to be recompiled into the server on
the next request.
-Java code used in the JSP™ page should remain simple so content designers
can easily understand what is taking place.
-Developers should encapsulate complex tasks within custom tags and Java
Beans components.

17
HTML to Java Bean Mapping

Java Bean
HTTP
Requests
JSP™ Page Java Bean
HTTP
Response
Java Bean

JSP™ (Developer
View)
Check if page needs
to be recompiled.
JSP™ Page
HTTP
Requests Web Server
Compile page
into servlet Java Bean
HTTP
Response
JAVA Java Bean
Load if needed
Servlet
And run servlet
Java Bean
JSP™ (Physical View)

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

The JSP™ page contains Fixed template Data to Java Bean Mapping.

18
JSP™ vs Servlet

• JSP
– Presentation centric
– HTML or XML with embedded Java
• Servlet
– Processing centric
– Java with HTML statements

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

19
Example Servlet

public class HelloServlet extends HttpServlet {


public void doGet(HttpServletRequest request,
HttpServletResponse response)
{
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("Hello World!");
out.println("<br>");
JspCalendar clock = new JspCalendar();
out.println("Today is");
out.println("<ul>");
out.println("<li>Day of month: ");
out.println("clock.getDayOfMonth());
out.println("</ul>");
out.println("</html>");
}
}
© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

20
Example JSP
<html>
Hello World!<br>
<jsp:useBean id="clock"
class=“calendar.JspCalendar” />
Today is
<ul>
<li>Day of month:
<%= clock.getDayOfMonth() %>
</ul>
</html>

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

21
Java Server Pages
Fundamentals

• Intent from the JSP™ 0.92 Spec:


– Model 1:

– Model 2:

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

22
What facilities does JSP™ give page
designer to build pages and access
Java beans ?
• The JavaServer Pages specification
includes:
– Standard directives.
– Standard JSP™ Tags.
– Scripting elements.
– Implicit Objects.
– A portable tag extension mechanism.

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

23
Directives

• Directives are messages to the JSP™


container and do not produce output into
the current output stream.
• They have a syntax as follows:
– <%@ directive {attr=value}* %>
• Important directives:
– page: Communicate page dependant
attributes and communicate these to the
JSP™ container.
– Taglib: Indicates a tag library that the
JSP™ container should interpret.

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

24
JSP™ Standard Tags

• Actions are used to access Java


objects from the JSP™ page.
• Example JSP standard tags:
<jsp:useBean id="clock"
class=“calendar.JspCalendar” />
<jsp:getProperty name=“customer”
property=“name” />
<jsp:setProperty name=“customer”
property=“name” param=“username” />
<jsp:include
page=“/templates/copyright.html” />
<jsp:forward page=“/displayPage.html” />

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

UseBean locates or create a bean of the specified class and gives it the
appropriate scope.
Object lifetime.
-page : PageContext : – page Scope
-request : HttpServletResponse – request Scope
-session : HttpSession – session scope.
-Application: ServletContext – application scope.
GetProperty and SetProperty – talk about param, or value
Jsp:include or jsp:forward – must not write to output buffer.

25
JSP™ Scripting Elements

• Declarations
<%! QuoteBean q; %>

• Scriptlets
<% q = new QuoteBean(); %>

• Expressions
<%= q.getQuote(“SUNW”); %>

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Three different scripting elements as called out.

Scriptlets and expressions look similar. You can assume that expressions are
returning a value. So they can be used in other statements, assignments,
expressions, etc.

26
Implicit Objects

• The author of a JSP™ page has access to


certain implicit objects that are always
available within scriptlets and
expressions, without being declared first.
• They are the following:
– request, response
– pageContext, session, applications
– out, config, page, exception

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

request – javax.servlet.ServletRequest – The request triggering the service


invocation.
response – javax.servlet.HttpServletRequest – The response to the request.
pageContext – javax.servlet.jsp.Pagecontext – context for JSP™ page
session – javax.servlet.http.HttpSession – The session object created for client
(if any)
application – javax.servlet.ServletContext – The servlet context from config
object
out – javax.servlet.jsp.JspWriter – The object that writes into the output stream
config – javax.servlet.ServletConfig – The ServletConfig for this JSP™ page.
page – java.lang.Object – The instance of the page’s implementation class.
Exception – java.lang.Throwable – the uncaught Throwable that results in an
error page being invoked.

27
JSP™ Sample

<%@ page info="My JSP™ example“ import="myclasses.*%>


Directive <jsp:useBean id="event“ class="com.sun.jspdemo.webImpl.Event" scope="session"
/>

Action <html>
<br>
<h3> The event name is: <jsp:getProperty name="event" property="name" /></h3>
<h3> The event description is: <%= event.getDescription() %></h3>

Expression <br>
<br>
<% if (event.getName().equalsIgnoreCase("appointment")) {
event.processAppointment(request.getParameter(“name”); %>
<jsp:include page="appointment.html" />
Scriptlet
<% }
else { %>
<jsp:include page="regular.html" /> Implicit
<% } %>
Object
</html>

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

28
Portable Tag Extension Mechanism

• Designing tag libraries allows content


developers to use custom tags instead
of java code.
• Using custom tags gives better
separation between content and
application logic.
– Minimizes the JAVA code in the page
– Uses a syntax that content designers are
familiar with. (They might no know Java)

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

29
Example using Tag Library

<html>
<%@ taglib uri=http://acme.com/taglibs/simpleDB.tld” prefix=“x” %>
<x:queryBlock connData=“conData1”>
<x:queryStatement>
SELECT ACCOUNT, BALANCE, FROM …
</x:queryStatement>
The top 10 accounts and balances are:
<table>
<tr><th>ACCOUNT</th><th>BALANCE</th></tr>
<x:queryCreateRows from=“1” to=“10”>
<td><x:queryDisplay field=“ACCOUNT”/></td>
<td><x:queryDisplay field=“BALANCE”/></td>
</x:queryCreateRows>
</table>
</x:queryBlock>
</html>

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

A fictitious tag library using 4 action to access a database.

30
Web Access

• Exposes the application to web client(s)


as coarse grained service(s):
• Responsible for handling “user” input/
application presentation
• Named via URI
• Modelled as HTML (or XML)
• Comprised of dynamic and static content
• Use JavaServer Pages™ technology (JSP)
for dynamic content:
• JSPs enable easy and rapid web
development, deployment and maintenance
• Easier to generate HTML and XML
© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

31
View Design Issues

• View Consists of two parts


– Request Processing
• (Part of the controller)
– Response Generation
• UI of your application

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

32
Tasks in Web Layer

Request
Validation
Business Logic

Control

Presentation

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

33
Typical Tasks

• Validation of Input
– Client and server-side validation
– Is form data complete and well-formed?
• Interaction with Business Logic
– Create data
– Extract data for this user
• Controller
– What is the next step in conversation?
• Presentation of content
– Present data to client

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

34
View

View: present User Interface (screen


representation of model)

Request Updates
Controller
Model
Customer

View
Selection
Display State Query
View
(read only)

JSP
Custom JSP Actions
JavaBeans Components
© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

35
View: Response Generation

• Determining which screen to show


next is the Job of the controller
• Build with JSP technology
• Use component model
– Custom tags
– JavaBeans™ architecture-based
components
– Runtime includes
• Use templates
– Common look and feel

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

36
When Servlets, When JSP™
Technology Based Components?

• Use JSP™ technology for response


generation
• Use servlets for dispatching, services,
or for generating binary content
• Example
– Request processing => both JSP™ and
servlet technologies are suitable
– Displaying shopping cart => use JSP™
technology
– Generating images => use servlets

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

37
How Do I Use All These Tools ?

• We always want “good”


separation between
content and application
logic: 1. Parse Request
– JSP™ pages that
contain mostly fixed
template data and
HTTP Sevlet
Requests
JSP™ actions and ns (Controller)
a
Be
directives. av
a
eJ
– Minimize scriptlets. e pa
r
Pr
– Move request
3. Forward Request to JSP™ Page
2.
processing out of
JSP™ page. Java Bean
JSP
Page
– JSP™ page is used (Model)
primarily for response (View)
generation. HTTP
– Characterized by the Response

MVC architecture.
© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

We are given a powerful tool from which we can do almost anything…


What is the appropriate way of using this tool so your applications are flexible,
scalable and facilitates team development.
Problems:
Which servlet do we send requests to.

38
View Design Guidelines

• Build View in the Web-tier


– Use JavaServer Pages™ (JSP™)
components for presentation layout
– Custom tags and JavaBeans™ components
for presentation logic

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

39
View Design Considerations

Design Considerations
– Servlet: for dispatching, control
between the Web tier and EJB
tier.
– JSP: benefit of separating
content and display logic, used
mainly for presentation

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

40
Java™ Programming Language Code (“Java
Code”) in the Page?

• Avoid Java code in JSP™ files


when possible
– Use reusable components or tags
for business logic
– Okay to have presentation related
code on the page, however better
to replace it with tags

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

41
When to use JavaBeans vs EJBs
for Data Base Access?

• JSP->Controller Beans->EJB
(transactions: account, request)
– Container manages the connection pooling
and transactions
– Encapsulates the enterprise information
system resources and the core application
logic
– Scales well
• JSP->JavaBeans->DB (read-only, static
data, infrequent changes: catalog)
– High performance(No EJB overhead)

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

42
How they all work together

• The request handled by a Servlet or


JSP, then forwarded to a JSP

EJBs

Request
Forward

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Explain the slide

43
#A

How do they all work together?


Presentation Application Logic
Logic Layout Business Data Access

Inventory
Entity Bean

update()
Manages data
main Controller
Servlet Session Bean
View Selection
doPost() purchaseItems()
Receives request Show Validates request
Validates input Confirmation Executes process OrderEJB
Calls session bean Page Enforces transactions
... Entity Bean
Calls JSP™ passing JSP
Value Model object Formats HTML create()
Responds to client Manages data

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Example: request to purchase Items


Presentation Logic: simple input validation
Controller Session Bean: full request validation. In short, it executes the
business process in an atomic transaction—
Entity Beans: manages the data in the data store. Reports any exceptions
Presentation Layout: given the results from the transaction, it displays the
results to the web browser or other client (could be HTML, XML, or other
format)

Question: why use a session bean? Why not execute from the servlet?
Answers:
Improves reuse to put all of the business logic in a component that can
be used by different types of clients
Improves network performance if servlets/EJBs are not co-located since
two (potentially large) entity objects don’t need to be referenced by the
client

44
#A

Example Servlet

public void doPost (HttpServletRequest req, HttpServletResponse res) {


String userId = req.getSession().getValue(“userId”);

IAccountHome accountHome;
IAccountBean account;

Context initCtx = new InitialContext();


accountHome = initCtx.lookup(“com/AccountHome”);
account = accountHome.findByPrimaryKey(userId);
accountDetails= account.getAccountDetails();
This is ugly — we need some help!
Writer out = res.getWriter();

X
out.println(“<HTML><HEAD><TITLE>Your account</TITLE></HEAD>”);
out.println(“<BODY>Name “ + accountDetails.getName() + ”.<br>”);
out.println(“Address: “ + accountDetails.getAddress() );



}

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

Example code displays name, address for a customer. It utilizes an account EJB (entity bean)
public void doPost (HttpServletRequest req, HttpServletResponse res) {
String userId = req.getSession().getValue(“userId”);

IAccountHome accountHome;
IAccountBean account;

Context initCtx = new InitialContext();


accountHome = initCtx.lookup(“com/AccountHome”);
account = accountHome.findByPrimaryKey(userId);
accountDetails= account.getAccountDetails();

Writer out = res.getWriter();


out.println(“<HTML><HEAD><TITLE>Your account</TITLE></HEAD>”);
out.println(“<BODY>Name “ + accountDetails.getName() + ”.<br>”);
out.println(“Address: “ + accountDetails.getAddress() );
}

45
#A

Example JSP
JSPs are a presentation layer for Servlets...
<HTML>
<HEAD>
<TITLE>Your account</TITLE>
</HEAD>
<BODY>
<%
AccountDetails ad = (AccountDetails)
req.getAttribute(“account”, accountDetails);

%>
Name : <%=ad.getName()%> <br>
Address: <%=ad.getAddress()%> <br>
</BODY>
</HTML>

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

46
#A

Example Servlet Dispatching to JSP

Servlets are Java’s answer to CGI/Perl...

public void doPost (HttpServletRequest req, HttpServletResponse res) {


String userId = req.getSession().getValue(“userId”);

IAccountHome accountHome;
IAccountBean account;

Context initCtx = new InitialContext();


accountHome = initCtx.lookup(“com/AccountHome”);
account = accountHome.findByPrimaryKey(userId);
AccountDetails accountDetails= account.getAccountDetails();
Writer out = res.getWriter();
This
Java isServer
ugly —Pages we needto the
somerescue!
help!
out.println(“<HTML><HEAD><TITLE>Your account</TITLE></HEAD>”);

X
RequestDispatcher dispatcher;
out.println(“<BODY>Welcome “ + accountDetails.getName + ”.<br>”);
ServletContext context
out.println(“Address: “ +=getServletContext();
accountDetails.getAddress() );

Why do I ••dispatcher
care? = context.getRequestDispatcher(“estore/Account.jsp”);
req.setAttribute(“account”, accountDetails);
}
• Enables separation of presentation logic from presentation layout
dispatcher.forward(req, res);
• Enable your experts to play to their strengths
© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

public void doPost (HttpServletRequest req, HttpServletResponse res) {


String userId = req.getSession().getValue(“userId”);

IAccountHome accountHome;
IAccountBean account;

Context initCtx = new InitialContext();


accountHome = initCtx.lookup(“com/AccountHome”);
account = accountHome.findByPrimaryKey(userId);
AccountDetails accountDetails= account.getAccountDetails();
RequestDispatcher dispatcher;
ServletContext context =getServletContext();
dispatcher = context.getRequestDispatcher(“estore/Account.jsp”);
req.setAttribute(“account”, accountDetails);
dispatcher.forward(req, res);
}

47
Single Entry Point Controller

1. Parse Request
JSP
HTTP Page
Java Component
Requests (Entry (Central Controller)
Point)
ns
B ea
va
Ja
a re
P rep
2.
JSP
Java Bean
(Model)
Page
(View)
HTTP
Response
A single entry point to an application makes security,
application state, and presentation uniform and easier
to maintain.

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

In order to keep the java code separate from the content one can delegate this
task to a java bean.

48
Blueprints MVC Architecture

HTTP
Requests
First
Component
2
1 request

Request HTTP Request to


Processor Event Translator
Screen event
Manager event
Web Tier EJB Tier
Controller Controller
Model Update
(Proxy)
Notification

JSP™
Java Beans Enterprise
Page Components Beans
(View)
Model Data Model
Mirror Data
HTTP
Response
Web Tier EJB Tier

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

49
Resources

• O'REILLY: Jason Hunter


• Govind Seshadri www.Jguru.com
www.javaworld.com

© Copyright 2000 Sun Microsystems, Inc., All rights reserved.

50

You might also like