All You Ever Wanted To Know About Servlets

Slides:



Advertisements
Similar presentations
Servlets & JSPs - Sharad Ballepu.
Advertisements

Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Servlets and Java Server Pages.
7 Copyright © 2005, Oracle. All rights reserved. Maintaining State in J2EE Applications.
CGI programming. Common Gateway Interface interface between web server and other programs (cgi scripts) information passed as environment variables passed.
E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
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.
Servlets and a little bit of Web Services Russell Beale.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 34 Servlets.
2/16/2004 Dynamic Content February 16, /16/2004 Assignments Due – Message of the Day Part 1 Due – Reading and Warmup Work on Message of the Day.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
All You Ever Wanted To Know About Servlets But Were Afraid to Ask.
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.
SE-2840 Dr. Mark L. Hornick1 Java Servlet-based web apps Servlet Architecture.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
Applets & Servlets.
1 Servlet How can a HTML page, displayed using a browser, cause a program on a server to be executed?
Publishing Data on the Internet Client 1 DB Internet Client 2 Client n.
Servlets, Sessions, and Cookies Lecture 8 cs193i – Internet Technologies Summer 2004 Kelly Shaw, Stanford University.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
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.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Session tracking There are a number of problems that arise from the fact that HTTP is a "stateless" protocol. In particular, when you are doing on- line.
Web Application Development * These slides have been adapted and modified from CoreServlets course material (Marty Hall) and LUMS cs391 (Umair Javed).
Java Servlets & Java Server Pages Lecture July 2013.
Chapter 6 Server-side Programming: Java Servlets
Introduction to ASP.NET1. 2 Web applications in general Web applications are divided into two parts –The server part –The client part The server part.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Session Management.
All You Ever Wanted To Know About Servlets But Were Afraid to Ask.
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.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
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.
Slides © Marty Hall, book © Sun Microsystems Press 1 Session Tracking Core Servlets & JSP book: More.
©SoftMooreSlide 1 Session Tracking with Servlets.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
CSC 2720 Building Web Applications Managing Users' States – Cookies, URL-Rewriting, Hidden Fields and Session Management APIs.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
Session Tracking Parts of this presentation was provided by SSE.
How CGI and Java Servlets are Run By David Stein 14 November 2006.
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.
Distributed Web Systems Java Servlets Lecturer Department University.
Java Server Pages Can web pages be created specially for each user?
JSP Implicit Objects CS 422 Dick Steflik.
Servlets.
Java Servlets By: Tejashri Udavant..
Sessions Many interactive Web sites spread user data entry out over several pages: Ex: add items to cart, enter shipping information, enter billing information.
Chapter 6 Server-side Programming: Java Servlets
Chapter 6 Server-side Programming: Java Servlets
Sessions.
SESSION TRACKING.
Chapter 26 Servlets.
Servlets and Java Server Pages
Introduction to Servlets
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
Cookies Cookies are small bits of textual information that a Web server sends to a browser and that the browser returns unchanged when later visiting the.
Sessions Many interactive Web sites spread user data entry out over several pages: Ex: add items to cart, enter shipping information, enter billing information.
Servlet Session Tracking: Session API
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Presentation transcript:

All You Ever Wanted To Know About Servlets But Were Afraid to Ask References: Programming The World Wide Web By Robert W. Sebesta ©2002 by Addison-Wesley Core Web Programming (2e) by Marty Hall and Larry Brown ©2001 by Sun Microsystems, Inc.

Three Embedded Scripting Languages ASP is proprietary to Microsoft and only works on certain servers JSP is an open standard for use with many servers Built on Java PHP is open source freeware All allow you to insert code, objects, and do text substitutions in webpages

Java Servlets Not as simple to use as JSP, but easier to install We don't have JSP at Dal FCS Run on the server (like SSI or CGI) Threaded (unlike SSI or CGI) Run inside the single JVM owned by http

But what about mod_perl? mod_perl is server-side and light weight (like a thread) Java has some network support that is more sometimes more convenient than using perl Particularly for session tracking

Session Tracking With Servlets Programs written in java produce output which is sent to the client like any CGI program

Session Tracking With Servlets All servlets implement the Servlet interface or extend a class the implements it Important methods: Init Service Destroy getServletConfig getServletInfo

Common Methods We will use HttpServlet and these methods: doGet doPost doPut doDelete init destroy getServletInfo One of those methods must be overridden for each servlet

Example: Hello Servlet Source Code Run it See Compilation Record Must be compiled and run from torch Note how it overrides the doGet method Which process runs the servlet?

Maintaining State There are 3 ways to maintain state? Cookies Hidden fields in forms Session level authentication

Maintaining State Ways to maintain state: Cookies Hidden fields in forms (or using URL rewriting to fake it) Session level authentication Servlets Uses cookies when user-agent supports it Uses URL rewriting if can't use cookies

Session Tracking Ways to maintain state: Cookies Hidden fields in forms URL rewriting Session-level authentication Servlets Will use cookies if possible Will use URL rewriting if no cookies

How Do Servlets Track The Session? Each session has a unique ID The first time a session is begun an ID is assigned Every subsequent connection must send the ID (through a cookie or the URL)

Servlet Sessions HttpSession session = request.getSession(); If null then this is a new session Force a new session like this… request.getSession(true);

Storing Information in Sessions setAttribute(String name, Object value) getAttribute(String name) removeAttribute(String name) getAttributeNames()

Information About Sessions getId() isNew() getCreationTime() getLastAccessedTime() getMaxInactiveInterval()

Example: Session Tracking Source Code Run it Note the encoding of the URL All examples are available at http://www.cs.dal.ca/~jamie/CS3172/Materials/examples/servlets/

Questions? Which process executes the servlets? How are they like CGI programs? How are they different from CGI programs? What advantages do they have over other technologies we've seen so far?