350 likes | 363 Views
Learn about Java Servlets and JSP features, J2EE architecture, Java Servlet architecture, benefits, and development with Oracle9i JDeveloper in this comprehensive course.
E N D
Building Servlet and JSP Applications with Oracle9i JDeveloper Speaker NameSpeaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation olivier.lediouris@oracle.com
Agenda • Java 2 Enterprise Edition - J2EE • Java Servlets and JavaServer Pages • JDeveloper Servlet and JSP Features • Building JSP applications
Agenda • Java 2 Enterprise Edition - J2EE • Java Servlets and JavaServer Pages • JDeveloper Servlet and JSP Features • Building JSP applications
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
Multiple Roles of Java Servlets 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
Java Servlet Architecture 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 Http Client HttpServlet doGet() { Process request from Client using Request object; Send response to client via the Response object; } Request Response Session
Java Servlets 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("<html><body>"); out.println(”<h1>Hello There!</h1>"); out.println("</body></html>"); 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("<?xml version=\"1.0\"?>"); out.println("<Employee>”); out.println(“<Name>Bob</Name>”); out.println("<Empno>12345</Empno>”); out.println("</Employee>”); out.close(); }
Life Cycle of a Servlet 1 2 3 Server Operations Client (Browser) Requests Handle 0 - N Client requests Load Initialize Destroy 4
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...
JavaServer Pages A Simple JavaServer Page example <HTML> <BODY> <P>Hello! <BR> Today is:<%= new java.util.Date() %> </BODY> </HTML>
JavaServer Pages A JavaServer Page using a JavaBean <HTML> <BODY> <jsp:useBean class=“beans.nameBean” id=“namebean” scope=“page”> Employees: <%=nameBean.showEmps() %> </BODY> </HTML>
Custom JSP Tags - 1.1 Custom Tag Libraries with JSP 1.1 <HTML> <BODY> <%@ taglib uri=“/myowntags.tld” prefix=“mytags” %> <P> Today’s Date is: <mytags:ShowDate format=“mm/dd/yy”> </BODY> </HTML>
How is a JSP Served? http://localhost:8080/Hello.jsp Java JSP Servlet Compiler Translator Runner JDBC Outputof Hello HTML /XML JSP SourceHello.jsp Generated file Hello.java Servlet class Hello JSP runtime
JSP Benefits • Performance! • Platform Independence • Easy xyML Development Environment • Extensible with Javabeans and Custom Tags <xml>, <html>, ….
Agenda • Java 2 Enterprise Edition - J2EE • Java Servlets and JavaServer Pages • JDeveloper Servlet and JSP Features • Building JSP applications
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
Oracle9i JDeveloper JSP/Servlet Features • 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 WAR/EAR OC4J
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