1 / 27

Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB

Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB. Outline. Big picture Servlets JavaServer Pages EJB. EJB Server. Web Server. Browser. DB. EJB. Servlet. HTML. DB. Browser. EJB. JSP. XML. Multi-Tiered Web-based application.

butch
Download Presentation

Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Overview of The Java Platform Solution for E-Business Applications :JSP, Servlet and EJB

  2. Outline • Big picture • Servlets • JavaServer Pages • EJB

  3. EJB Server Web Server Browser DB EJB Servlet HTML DB Browser EJB JSP XML Multi-Tiered Web-based application

  4. What are Servlets? • Extend HTTP Server • Dynamic content • Servlets are lightweight • Run in web server process • exploit Java security • Built on Java Platform • Full access to Java APIs • Easy to develop. Write once, run anywhere

  5. HTTP Requests & Response • Client makes HTTP request • Request is resolved to Servlet • Container • creates servlet • invokes init() • creates request and response objects • invokes service() • Sevlet interact with response • Container replies to HTTP request • Container may • invoke destroy(), dispose servlet at anytime

  6. A servlet example 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 JspCalender(); out.println("Today is"); out.println("<ul>"); out.println("<li>Day of month: "); out.println(clock.getDayofMonth()); out.println("<li>Year: "); out.println(clock.getYear()); out.println("/<ul>"); out.println("</html>"); } }

  7. As a JSP page <html> Hello World! <br> <jsp:useBean id="clock" class="calendar.JspCalendar"> Today is <ul> <li>Day of month:<%=clock.getDayofMonth()%> <li>Year: <%=clock.getYear()%> </ul> </html>

  8. JavaServer Pages (JSP) • JSP builds on servlet semantics • “inside-out” servlets (JSP can be precompiled into Servlet to reduce start up time) • Benefits • Easier to author, separate presentation logic from business logic • Exploits: • server-side scripting • templates • encapsulation of functionality

  9. Distributed Java Component Model -

  10. The Problem • Developing enterprise applications is HARD • Developing enterprise applications is EXPENSIVE • Enterprise applications are a NIGHTMARE TO MAINTAIN • Enterprise applications are COMPLEX TO ADMINISTER

  11. Why is it HARD? • Difficult to reuse application code across • hardware platforms • software platforms • servers • databases • Service needs grow more complex • threading • persistence • transactions

  12. What is EJB? • It’s server component model • It’s part of Java platform for the enterprise • It’s a specification (for software interoperability) • It enables development and deployment of Java applications that are: • Distributed – via RMI • Scalable • Transactional • Secure

  13. Distributed component models -we are in heaven ... IIOP IIOP IIOP CORBAServerService RMIServerService RMIClient JRMP

  14. The underlying mechanism...

  15. Advantages of server side component model • Using pre-developed pieces of application • Transparent access to the distributed services, i.e. hiding the complexity of the technical environment • Components can be shared across the Enterprise • Using tools to wire components together

  16. EJB Architecture

  17. EJB Architecture

  18. EJB Main Components • Client • Any application or service requesting a service • Can be written in any language • Can’t access EJBs directly; must go through RMI and container • Name lookup via JNDI • EJB Servers • Contains and runs 1 or more containers • Resource management • process, thread, and connection pools • Remote management API

  19. EJB Main Components • EJB Containers • Actually host the beans • Provide naming (via JNDI), life cycle, persistence, security, transactions through call interception • EJB Components • Are distributed, transactional, and secure • Simple, single threaded, and non-re-entrant • Developer or tool generated • Contain business logic

  20. Roles in developing EJB • Enterprise Bean provider • Application Assembler • Deployer • EJB Server Provider • System Administrator

  21. Varieties of EJBs • Session beans • Model application tasks • Not shared, client specific • Transient state • Short lived • Example – an object holds the logic for purchasing product items i.e. buyProduct

  22. Varieties of EJBs • Entity bean • Model persistent resources • Shared by clients • Persistent state • Long lived • Example – a product to be purchased in a shop

  23. Programming basics – Classes and Interfaces • Remote interface • Defines the bean’s business methods • Extends javax.ejb.EJBObject • Home interface • Defines the bean’s life cycle methods (creating, removing and finding a bean) • Extends javax.ejb.EJBHome

  24. Programming basics – Classes and Interfaces • Bean class • Must have methods matching the signatures of the methods defined in the remote interface • Must have methods corresponding to some of the methods in the home interface • Primary key • Provides a pointer into the database • Only entity beans need a primary key

  25. The Unseen Pieces Client EJB Server EJB home stub home interface home interface EJB home remote interface EJB Object bean class remote interface EJB object stub RMI allows the downloadable stub

  26. Big picture again

  27. Several good introduction material on the web http://java.sun.com/products/ejb/articles/multitier.html This article shows a very good example on how to use EJB to develop multi-tier application!!! The example pretty much covers every thing (Session Bean, EntityBean and Servlet). http://java.sun.com/products/ejb/faq.html The FAQs on Sun EJB web site answered many general questions regarding to EJB. http://internt.isk.kth.se/~enander/DistObj/ejb/ejbpre.htm here's a good EJB presentation

More Related