Advanced Java Session 6 New York University School of Continuing and Professional Studies.

Slides:



Advertisements
Similar presentations
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
Advertisements

8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
JSP and Servelets.
CGI programming. Common Gateway Interface interface between web server and other programs (cgi scripts) information passed as environment variables passed.
M-V-C for web applications. Model for Web Applications model consists of data and system state database tables –persistent data session information –current.
Servlets, JSP and JavaBeans Joshua Scotton.  Getting Started  Servlets  JSP  JavaBeans  MVC  Conclusion.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
Apache Tomcat as a container for Servlets and JSP
Java Server Pages (JSP)
Java Servlets Java Server Pages (JSP)
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
An introduction to Java Servlet Programming
JSP Java Server Pages Reference:
Servlets CS-328 Dick Steflik. What is a servlet A Java application run on a thread of the webserver in response to an HTTP GET or POST request. The servlet.
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
Servlets Written by Dr. Yaron Kanza, Edited by permission from author by Liron Blecher.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
Servlets. Our Project 3-tier application Develop our own multi-threaded server Socket level communication.
Java Servlets.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Servlets, Sessions, and Cookies Lecture 8 cs193i – Internet Technologies Summer 2004 Kelly Shaw, Stanford University.
1 Chapter 1: Overview of Servlets and JavaSerevr Pages.
Java Servelets. What Is a Servlet? A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
Objectives Java Servlet Web Components
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
CSC 2720 Building Web Applications
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Java Servlets & Java Server Pages Lecture July 2013.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
1 CS122B: Projects in Databases and Web Applications Spring 2015 Notes 03: Web-App Architectures Professor Chen Li Department of Computer Science CS122B.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
Servlets O. De Pertat. Servlets Overview Generic Server Business logic API Java Syntax: classes extending the javax.servlet.Servlet interface or any sub-class.
Java Server Pages (JSP)
Java Server Pages An introduction to JSP. Containers and Components Several clients – one system.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
Java Servlets and Java Server Pages Norman White Stern School of Business.
1 Java Servlets l Servlets : programs that run within the context of a server, analogous to applets that run within the context of a browser. l Used to.
Servlets.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
J2EE T ECHNOLOGIES These are the technologies required to build large scale distributed applications, can be divided into – Component Technologies eg.
Java Servlets Java Server Pages (JSP)
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
K. K. Wagh Polytechnic, Nashik
Java Servlets and Java Server Pages
SERVLET THETOPPERSWAY.COM
How CGI and Java Servlets are Run By David Stein 14 November 2006.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
1 Lecture 8 George Koutsogiannakis/Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
Java Servlets References: Karen Anewalt, Mary Washington College.
CS122B: Projects in Databases and Web Applications Spring 2017
Introduction to Servlets
CS122B: Projects in Databases and Web Applications Winter 2017
Java Servlets By: Tejashri Udavant..
Pre-assessment Questions
CS122B: Projects in Databases and Web Applications Winter 2018
CS122B: Projects in Databases and Web Applications Spring 2018
Servlet APIs Every servlet must implement javax.servlet.Servlet interface Most servlets implement the interface by extending one of these classes javax.servlet.GenericServlet.
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

Advanced Java Session 6 New York University School of Continuing and Professional Studies

2 Objectives Java Servlets –BasicServlet –Accessing Form Data, HTTP Headers, CGI Variables –Cookies and Sessions Java Server Pages –Overview of Java Server Pages –Using Java Beans in JSP Integrating Java Servlets and JSP

3 Web Applications Architecture client Web server App server Backend Services such as db, quote server

4 Java Servlets Modern replacement for CGIs Server components written in Java Advantages of Servlets –Efficient –State Management –Portable –Robust –Extensible –Quick Development –Widespread Acceptance

5 Application Server Model services Servlet container servlets

6 Classes and Interfaces Servlet ServletConfig ServletContext GenericServlet ServletRequest ServletResponse HttpServlet HttpServletRequest HttpServletResponse HttpSession Cookie

7 GenericServlet Abstract class public void init() throws ServletException public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException public void destroy()

8 HttpServlet Abstract class protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException

9 BasicServlet example tomcat env javac BasicServlet.java servit BasicServlet.class tomcat start

10 Accessing Form Data String getParameter(String) Enumeration getParameterNames() ShowParameters.java

11 Accessing HTTP Headers String getMethod() String getRequestURI() String getProtocol() Enumeration getHeaderNames() ShowRequestHeader.java

12 Accessing CGI Variables String getAuthType() String getContentLength() String getContentType() ……. More complete list is in the handout. ShowCGIVariables.java

13 Generating Response setContentType() getWriter() …… More in the handout.

14 Handling Sessions Object getAttribute(String name) void setAttribute(String name, Object value) Enumeration getAttributeNames() void removeAttribute(String name) void Invalidate() ShowSession.java

15 Java Server Pages Use embedded java code in HTML files “automatically generated” servlet Part of the J2EE framework Supported by most Application Servers

16 Jsp Servlet Java Server Pages turn into a servlet Engine translates JSP into a java servlet, compiles it and executes it. HttpJspPage interface is a subclass of Servlet JSP engine provides a class that implements HttpJspPage interface _jspService method is the main entry point

17 Embedded Tags

18 Embedded Java code hello item number

19 page directives Language Import contentType errorPage Extends isErrorPage isThreadSafe Session autoFlush Buffer

20 Using Java Beans in Java Server Pages Basic Bean Use

21 Accessing Bean Properties <jsp:setProperty name=“book1” property=“title” value=“Developing Applications in J2EE”/>

22 Associating properties with HTML input parameters BookEntry example

23 Extending JSP with custom tags body text TagSupport class implements Tag BodyTagSupport class implements BodyTag Tag Library Descriptor

24 Integrating Servlets and Java Server Pages Use servlets for presentation logic User jsp for layout Jsp can also generate XML Examples: ShowPage.java ShowError.java

25 Thank you