Java Servlets By: Tejashri Udavant..

Slides:



Advertisements
Similar presentations
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Advertisements

MC365 Application Servers: Servlets. Today We Will Cover: What a servlet is The HTTPServlet and some of its more important methods How to configure the.
Servlets and a little bit of Web Services Russell Beale.
An introduction to Java Servlet Programming
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
Introduction to Servlet & JSP
Session-02.
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.
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.
Java Servlets & Java Server Pages Brad Rippe Fullerton College.
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 Pranav Maydeo. What is a Servlet ? Servlets are modules of Java code that run in a server application to answer client requests. Servlets are.
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
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
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.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Java Servlets & Java Server Pages Lecture July 2013.
Java Servlets Lec 27. Creating a Simple Web Application in Tomcat.
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
Java Servlet API CGI / HTTP Concepts Java Servlet API.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
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.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
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.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
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.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
Java Servlets and Java Server Pages
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
How CGI and Java Servlets are Run By David Stein 14 November 2006.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Chapter 4 Request and Response. Servlets are controlled by the container.
1 Lecture 8 George Koutsogiannakis/Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
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
Servlets.
Servlet Fudamentals.
CSE 403: Servlet Technology
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Introduction to Java Servlets on Jakarta Tomcat
Pre-assessment Questions
HTTP Servlet Overview Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might.
Servlet API and Lifecycle
CHAPTER 10 Servlet Programming
Chapter 26 Servlets.
Java Servlets & Java Server Pages
CS122B: Projects in Databases and Web Applications Winter 2018
Introduction to Servlets
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.
Objectives In this lesson you will learn about: Need for servlets
Web Search Interfaces.
Java Servlets and JSP.
Introduction to Java Servlets
CS122B: Projects in Databases and Web Applications Winter 2019
Java Chapter 7 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Java Servlets By: Tejashri Udavant.

What is a Servlet? A servlet is a java class that extends an application hosted on a web server. Handles the HTTP request-response process (for our purposes) Often thought of as an applet that runs on a server. Provides a component base architecture for web development, using the Java Platform The foundation for Java Server Pages (JSP). Alternative to CGI scripting and platform specific server side applications.

Common Uses Processing and/or storing data submitted by an HTML form. Providing dynamic content, e.g. returning the results of a database query to the client. Managing state information on top of the stateless HTTP, e.g. for an online shopping cart system which manages shopping carts for many concurrent customers and maps every request to the right customer.

Architectural Roles Servlets provide the middle tier in a three or multi-tier system. Servlets provide logic and/or traffic control for requests/response to the server. Servlets allow web developers to remove code from the client and place the logic on the server.

Architectural Roles Connection management Business rule enforcement Transaction management Mapping clients to a redundant set of servers Supporting different types of clients such as pure HTML, WML clients, other Java based clients

What is required? Servlets are not run in the same sense as applets and applications. Since they extend a web server, they require a servlet container to function. A servlet container is a part of a web server or application server that provides the network services over which request and response are sent. Contains and manages the servlets through there lifecycle. The container provides other services as well.

Web Container/Servlet engine J2EE Container Java Classes Servlets Browser Web Server Deployment Descriptor is used to configure web applications that are hosted in the App Server. Deployment Descriptor web.xml

Web Application Directory Structure Application Root (htdocs/wwwroot) WEB-INF/web.xml WEB-INF/classes Compiled servlet classes and other utility classes WEB-INF/lib Any required third party jars All J2EE compliant App Servers require this directory structure

Overview of the Servlet API All servlets implement the Servlet interface. The API provides two classes that implement this interface, GenericServlet and HttpServlet Servlet API is specified in two packages, javax.servlet and javax.servlet.http

Servlet Interface This is a contract between the servlet and the web container. Guarantees that all containers can communicate with a servlet. public void init(ServletConfig) public void service(request, response) public void destroy() public ServletConfig getServletConfig() public String getServletInfo()

HttpServlet Abstract class that extends GenericServlet Provides additional methods that are called by the service() method automatically. Both methods throw ServletException and IOException Methods of most concern: protected void doGet(HttpServletRequest, HttpServletResponse) protected void doPost(HttpServletRequest, HttpServletResponse)

Servlet Life Cycle Instantiation – web container creates an instance. Initialization – container calls the instance’s init(). Service – if container has request, then it calls the service() method Destroy – before reclaiming the memory (destroying the servlet), the container calls the destroy() method. Unavailable – instance is destroyed and marked for GC.

HttpServletRequest & HttpServletResponse Interfaces used for accessing request parameters and constructing client responses. The web container has concrete objects which implement these interfaces and passes into the servlet.

HttpSession Web containers provide an implementation of this interface to provide session tracking. Session objects can be retrieved from the HttpRequest object also provided by the container. HttpSession session = request.getSession(); If a session object does not exist for the client, one will be created. The duration of this session object can be configured in the web.xml file or in a servlet, setMaxInactiveInterval( int interval );

Servlet Context Servlet API provides an interface for storing information that is relevant to all servlets being hosted in a web application. Common for facilities like application logging, access to other resources (Database Connection Pools), and request dispatching. There is one context per web application per JVM. Parameter information is configured in the web.xml file in name/value pairs.