jsp and servlets in j2ee [ sun microsystems presentation ]

12
Slide 1 JSP and Servlets in J2EE Danny Coward Java Servlet specification lead, Sun Microsystems

Upload: kushallakhotia

Post on 07-Apr-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 1/12

Slide 1

JSP and Servlets in J2EE

Danny CowardJava Servlet specification lead,

Sun Microsystems

Page 2: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 2/12

Slide 2 Sun Microsystems Inc 

Agenda

" The role of JSPs and Servlets in the J2EEplatform

" Why and when to use JSPs and Servlets inJ2EE platform

" A particular example" Conclusion

Page 3: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 3/12

Slide 3 Sun Microsystems Inc 

Multi-Tiered Enteprise Apps

Application

PureHTML Web Server

XML

J2EE PlatformBrowser

JSP

Servlet

EJB

EJB

EJB

EnterpriseInformation

Systems

JavaApplication

Page 4: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 4/12

Slide 4 Sun Microsystems Inc 

Web Components in J2EE

" Web Components form the window to J2EE" Allows web layer to focus on what its good

at - presentation" Allows reuse of business logic elsewhere"

Allows scalability

Page 5: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 5/12

Slide 5 Sun Microsystems Inc 

J2EE Services

" Security" Naming" Database" Transactions"

Enterprise Java Beans (EJB)" JavaMail

Page 6: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 6/12

Slide 6 Sun Microsystems Inc 

Migrate or not ?

" If you want to make your business logicre-usable to other parts of the organisation

" If you want to take advantage of a secure,robust, transactional infrastructure

"If you want to connect into an interoperableenvironment and access InformationSystems

Page 7: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 7/12

Slide 7 Sun Microsystems Inc 

How to Migrate

" Separate semantics within a web application" Use JSP and Servlet components as

presentation layer for data" Move business logic out of web components

into separate components e.g. Tag Libraries" Migrate business logic to EJB

Page 8: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 8/12

Slide 8 Sun Microsystems Inc 

Interaction with EJB: Example

" Example: Online music store" Web front end, with functionality to:-

" Browse catalog

" Sign in

" Make purchases using 'shopping cart'

Page 9: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 9/12

Slide 9 Sun Microsystems Inc 

Example application contents:-

" Web Layer:-" Static content

" Catalog browsing JSPs" Checkout form Servlet

" EJB layer" Catalog entity bean" Shopping cart session bean" Account entity bean

"

Page 10: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 10/12

Slide 10 Sun Microsystems Inc 

Code example: Checkout Servlet

import javax.naming.*; 

 // create JNDI initial context

Context context = new InitialContext();

 // lookup EJB Home

Object objref = context.lookup("java:comp/env/AccountEJB");

HelloHome hello =

PortableRemoteObject.narrow(objref, HelloHome.class);

Hello ejb = hello.create();

servletOutput.println("<bold>You ordered " +

ejb.getOrderCount() + " CDs today.</bold>");

Page 11: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 11/12

Slide 11Sun Microsystems Inc 

Resources

" www.java.sun.com/j2ee" J2EE Reference Implementation

" Samples

" APM" Best practices document

" Example application

Page 12: JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

8/3/2019 JSP and Servlets in J2EE [ Sun Microsystems Presentation ]

http://slidepdf.com/reader/full/jsp-and-servlets-in-j2ee-sun-microsystems-presentation- 12/12

Slide 12 Sun Microsystems Inc 

Summary

" The web layer is the window into J2EE