Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications with Oracle9i JDeveloper
Java 2 Enterprise Edition - J2EE Java Servlets and JavaServer Pages JDeveloper Servlet and JSP Features Building JSP applications Agenda
The J2EE Architecture
Oracle and J2EE
Java 2 Enterprise Edition - J2EE Java Servlets and JavaServer Pages JDeveloper Servlet and JSP Features Building JSP applications Agenda
Java Servlets What Are Servlets? –Servlets are platform-independent, server-side Java components which extend an HTTP server Like mini-webservers HttpServlet - Dynamic Page generation (HTML, XML, …) –Superior to inefficient CGI and proprietary APIs (ISAPI, NSAPI …)
Java Servlets What Are Servlets? –Portable to any Application Server with Java Virtual Machine –Servlets have access to the entire family of Java APIs JDBC EJB JavaMail... Widespread industry acceptance
Java Servlets provide many useful services Provides low-level API for building Internet Services Serves as foundation to JavaServer Pages Can deliver multiple types of data to any client –XML, HTML, WML, GIF, etc... Can serve as “Controller” of JSP/Servlet application Multiple Roles of Java Servlets
The ServletRequest Object Encapsulates all request information from the client –request headers –form data and query parameters –other client data {session info, cookies, path...etc.} The ServletResponse Object Encapsulates all data sent back to client –response headers –OutputStream to write data to the client –setting cookies Java Servlet Architecture
The HttpSession Object Allows for the storage of transient, session data Easy way to identify a single user between page requests Servlets can obtain data from session, modify and store it again Typical Example - Online Store Customer profile information Shopping Cart Java Servlet Architecture
HttpServlet doGet() { Process request from Client using Request object; Send response to client via the Response object; } Request Response Http Client Session
A Hello HttpServlet example public class HelloServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.setContentType(“text/html”); out.println(" "); out.println(” Hello There! "); out.println(" "); out.close(); } Java Servlets
A Servlet which sends XML data public class FormServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.setContentType(“text/xml”); out.println(" "); out.println(" ”); out.println(“ Bob ”); out.println(" ”); out.println(" ”); out.close(); } Java Servlets
LoadInitialize Handle 0 - N Client requests Destroy Life Cycle of a Servlet Server Operations Client (Browser) Requests
Servlet Benefits Performance! Platform Independence Rich Development Environment Broad Industry Acceptance
JavaServer Pages What is a JavaServer Page? –JavaServer Pages separate content presentation from content generation. –Provides a simple and fast way to build dynamic page content (HTML, XML, etc) xyML with embedded Java code Extensible with components & custom tags
JavaServer Pages & Servlets JavaServer Pages are based on Servlet technology –JSP container is a Servlet –Each JSP is compiled into runtime Servlet –Same performance and portability benefits from Servlet technology but with the ease of use of markup language Best of both worlds for web designers and web developers
JavaServer Pages JavaServer Pages consist of HTML pages with special tags which allow for inclusion of Java logic –Scriptlets –Directives –Expressions –Declarations –Other Tags - UseBean, setProperty...
A Simple JavaServer Page example Hello! Today is: JavaServer Pages
A JavaServer Page using a JavaBean Employees: JavaServer Pages
Custom JSP Tags Custom Tag Libraries with JSP 1.1 Today’s Date is:
How is a JSP Served? Java Compiler Servlet Runner JSP Translator JSP Source Hello.jsp Generated file Hello.java Servlet class Hello Output of Hello HTML /XML JDBC JSP runtime
JSP Benefits Performance! Platform Independence Easy xyML Development Environment Extensible with Javabeans and Custom Tags <xml>,<html>,….
Java 2 Enterprise Edition - J2EE Java Servlets and JavaServer Pages JDeveloper Servlet and JSP Features Building JSP applications Agenda
Existing JDeveloper JSP/Servlet Features HttpServlet Wizard JSP Wizard Integrated JSP/Servlet runtime BC4J Data Tag Library –Code generation with Datapage wizard Local and Remote Debugging
Oracle9i JDeveloper JSP/Servlet Features Built-in OC4J runtime container –OC4J (Servlet/JSP/EJB) OC4J
Customizable Component Palette Oracle9i JDeveloper JSP/Servlet Features
JSP Insight –Tag Insight –Java Insight Oracle9i JDeveloper JSP/Servlet Features
Improved BC4J Data Tag Library –More useful/flexible Tags –Component Tags Oracle9i JDeveloper JSP/Servlet Features
JSP Code Generation Templates Oracle9i JDeveloper JSP/Servlet Features
J2EE WAR and EAR Deployment –Deploys to standard WAR and EAR files –One-Click Deployment to Oracle9iAS –Weblogic Deployment Support OC4J Oracle9i JDeveloper JSP/Servlet Features WAR/EAR
Demonstration JSP & Servlet Development in Oracle9i JDeveloper This demonstration shows you how to: Build and debug simple servlets and JSPs Use custom JSP tag libraries –Customize Component Palette Build BC4J based JSP applications Deploy a BC4J JSP application to Oracle9iAS
Summary In this Presentation you have learned: Servlet and JSP Basics How to build and debug Servlets and JSPs with Oracle9i JDeveloper How create BC4J JSP applications and deploy them to Oracle9iAS
& Q U E S T I O N S A N S W E R S Q&A