All You Ever Wanted To Know About Servlets But Were Afraid to Ask.

Slides:



Advertisements
Similar presentations
Servlets & JSPs - Sharad Ballepu.
Advertisements

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialitica in Informatica – Università di Trento.
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 Web Search Interfaces. 2 Web Search Interface Web search engines of course need a web-based interface. Search page must accept a query string and submit.
1 Servlets Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun.
Java Server Pages (JSP)
 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.
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?
Servlet Session Tracking II Session API All material and examples are from
Java Server and Servlet CS616 Team 9 Kim Doyle, Susan Kroha, Arunima Palchowdhury, Wei Xu.
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.
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 Servlet Technology. Introduction Servlets are Java programs that run on a Web server, handle HTTP requests and build Web pages Servlet specification.
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.
Session Tracking - 2 Lec 32. Last Lecture Review  Session Tracking – why?  Need to store state – typical solutions Cookies – already learned URL Rewriting.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
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.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development Session II: Introduction to Server-Side Web Development with Servlets.
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.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
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.
Slides © Marty Hall, book © Sun Microsystems Press 1 Session Tracking Core Servlets & JSP book: More.
©SoftMooreSlide 1 Session Tracking with Servlets.
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.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
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.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Java Database Connectivity.
Distributed Web Systems Java Servlets Lecturer Department University.
JSP Implicit Objects CS 422 Dick Steflik.
Servlets.
Sessions Many interactive Web sites spread user data entry out over several pages: Ex: add items to cart, enter shipping information, enter billing information.
Java Servlets.
Sessions.
SESSION TRACKING.
Chapter 26 Servlets.
Introduction to Servlets
All You Ever Wanted To Know About 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.
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
Presentation transcript:

All You Ever Wanted To Know About Servlets But Were Afraid to Ask

2 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

3 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

4 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

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

6 Session Tracking With Servlets All servlets implement the Servlet interface or extend a class the implements it Important methods: InitServiceDestroy getServletConfiggetServletInfo

7 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

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

9 Session Tracking Four ways to maintain state: 1.Cookies 2.Hidden fields in form s 3.URL rewriting 4.Servlets Will use cookies if possible Will use URL rewriting if no cookies

10 How Does The Servlet 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)

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

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

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

14 Example: Session Tracking Source Code Run it Note the encoding of the URL All examples are available at

15 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?