Construction d Applications Réparties / Master MIAGE

Size: px
Start display at page:

Download "Construction d Applications Réparties / Master MIAGE"

Transcription

1 Construction d Applications Réparties / Master MIAGE HTTP and Servlets Giuseppe Lipari CRiSTAL, Université de Lille February 24, 2016

2 Outline HTTP HTML forms Common Gateway Interface Servlets

3 Outline HTTP HTML forms Common Gateway Interface Servlets

4 The browser A web-brower is a generic client that can do several things Request and show static html documents (web-pages) together with images, audio and video CSS is used to present a document in one specific way Send data (through forms) using the POST command Execute scripts (e.g. Javascript) Execute java applets Therefore, one possible way of implementing a distributed system is to use the browser as Rich-Client Platform (RCP) In this case, programming client side is a mixture of HTML, CSS, Javascript (and maybe Flash or Java applets)

5 The server A classic web server (e.g. Apache, IIS, etc.) implements basic services like retrieving a html file, together with images and other A/V files However it is possible to extend these basic functionalities by implementing additional services using appropriate scripting languages (PHP, JSP, etc.) running external programs (CGI-bin, Servlets, etc.) Advantages: reuse of existing code increased portability (thanks to HTTP/HTML, etc.) uniform presentation Disadvantages not all browsers adhere to the same standards more difficult to program distributed systems with state (it depends on the platform)

6 Basic functioning 1, 2: establish TCP connection 3: get method demanding an HTML file 4: send the HTML file The client requests the additional files (CSS, images, etc.)

7 Commands Two main commands GET for getting files / resources (Server -> Client) POST for uploading information (Client -> Server) When you visit a web page, you normally use GET When you compile a form, or when you upload a file, you use POST

8 Authentication HTTP uses the Basic Authentication Stateless: the credentials must be sent at every request Credentials are login/password in the header The server responds with HTTP/ Unauthorized WWW-Authenticate: basic realm="apps" The Client sends a new request with GET /somedir/somefile.html HTTP/1.1 User-agent:... Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l The string "login:password" is coded using the RFC2045-MIME variant of Base64

9 Caching The client can store copies of the files if the file has not changed, the server does not need to send it The client sends the header field If-modified-since: <date> If the server has a newer copy, it sends a normal response, otherwise it sends HTTP/ Not Modified A Proxy is a local server used as a "closer copy" of the remote server it is useful to reduce network congestion it can be used in the presence of firewalls

10 Stateful communication HTTP is stateless if we want to maintain some state, we have to send the state information in every message Various methods Cookies Hidden form fields

11 Cookies A cookie is a string value, generated by the server, that the browser can store and send in the following messages

12 Cookies There are various types of cookies Session cookies do not have an expiration date. They are usually deleted by the browser when it is closed, so they are usually tied to the "session". Permanent cookies have an expiration date, that can be very long, so they persist after the user closes the browser sometimes called tracking cookies because they can be used to record the browsing history

13 Cookie domain Every cookie is associated to a domain Normally, a cookie s domain attribute will match the domain that is shown in the web browser s address bar (first-party cookie) Third-party cookies, however, belong to domains different from the one shown in the address bar Example: The user visits which contains an advertising banner belonging to ad.foxytracking.com which sets a third-party cookie When the user later visits which also contains a banner from the same advertiser, the banner can read the previous cookie and build the history From wikipedia: "As of 2014, some websites were setting cookies readable for over 100 third-party domains. On average, a single website was setting 10 cookies, with a maximum number of cookies (first- and third-party) reaching over 800."

14 Cookie attributes A cookie is identified by A name, a value, and several attributes Example: Request: GET /index.html HTTP/1.1 Host: Response: HTTP/ OK Content-type: text/html Set-Cookie: theme=light Set-Cookie: sessiontoken=abc123; Expires=Wed, 09 Jun :18:14 GMT Next Request: GET /spec.html HTTP/1.1 Host: Cookie: theme=light; sessiontoken=abc123

15 Cookie attributes The Domain and Path attributes define the scope of the cookie. For obvious security reasons, cookies can only be set on the current resource s top domain and its sub domains If a cookie s domain and path are not specified by the server, they default to the domain and path of the resource that was requested (but not the subdomains) The Expires attribute defines a specific date and time for when the browser should delete the cookie. The date/time is specified in the form Wdy, DD Mon YYYY HH:MM:SS GMT Alternatively, the Max-Age attribute can be used to set the cookie s expiration as an interval of seconds in the future, relative to the time the browser received the cookie The Secure attribute is meant to keep cookie communication limited to encrypted transmission The HttpOnly attribute directs browsers not to expose cookies through channels other than HTTP (and HTTPS)

16 Outline HTTP HTML forms Common Gateway Interface Servlets

17 Forms A HTML form may contain: text areas (for input of long texts) buttons checkboxes radio buttons menus The client can enter data and then send it to the server by clicking on the final "submit" button

18 Example of HTML form <html><body> <form action=" method="post"> <p>name <input name="client" size="46"/></p> <p>street <input name="street" size="40"/></p> <p>city <input name="city" size="20"/> Postal code <input name="cp" size="5"/></p> <p>credit card number <input name="carte" size="10"/> Expiration date <input name="expire" type="text" size="4"/></p> <p>mastercard <input name="cc" type="radio" value="mc" checked/> VISA <input name="cc" type="radio" value="visa"/></p> <p><input type="submit" value="submit"/> <input type="reset" value="reset"/></p> </form> </body></html>

19 Submission When the user press the "Submit" button the browser builds a string containing pairs field = value the pairs are separated by character & spaces are encoded as + characters + & = are encoded as %2B %26 %3D Example client=jean+vier&rue=54+rue+gambetta&ville=paris& cp=75001&carte= &cc=vis The string is sent in the message body part of a HTTP POST method

20 Submitting a file <html> <body> <form action=" method="post" enctype="multipart/form-data"> <p>password <input name="passe" size="16" type="password"/> </p> <p>select a file <input name="fichier" type="file"/> </p> <p><input type=submit value="submit"/> <input type=reset value="reset"/> </p> </form></body> </html> Header Content-Type: multipart/form-data; boundary= d225420d803c8 Body d225420d803c8 Content-Disposition: form-data; name="image.gif"; filename="..." Content-Type: image/gif GIF89a&... binary content d225420d803c8

21 Hidden field It is possible to hide a field that contains a certain value <input name="cache" value="gl" type="hidden"> This can be used by some server to keep state between successive requests the field value is sent to the server with the next "submit" action for example, the value of the hidden field may contain an user-id generated by the server, or other stateful information <html> <body> <form action=" method="post"> Hidden field <input name="hdn" value="gl " type="hidden"/><br/> <input value="click" onclick="functionjavascript()" type="button"/><br/> <input type="submit" value="send"/> <input type="reset" value="reset"/><br/> </form> </body> </html>

22 Hidden field protocol Similar to a cookie, an hidden field can be used to maintain state between successive requests 1. The server sends a form containing an hidden field (which identifies the user/session) 2. The user fills in the form and clicks on the "Submit" button 3. The browser sends a POST request containing the value of the hidden field in the parameter string 4. The server can look up for the value to identify the user/session, and respond appropriately

23 Outline HTTP HTML forms Common Gateway Interface Servlets

24 CGI CGI stands for Common Gateway Interface it is a standard way to execute a generic script or program on the server side for example a program that processes a POST method to process/store the form data a program/script that dynamically generates a web page Any kind of program: bash shell scripts, Perl, Python, exec files, etc. Programs are denoted by a URL by convention, all CGI programs are located in cgi-bin/ For several reasons, this approach is less and less used

25 CGI - passing parameters Either with GET or POST GET, values encoded in the url GET /cgi-bin/anniversaire.pl?mois=aout&jour=11 HTTP/1.0 POST, values encoded in the body POST /cgi-bin/anniversaire.pl HTTP/1.0 Content-type: application/x-www-form-urlencoded Content-length: 20 mois=aout&jour=11 Data passed to CGI via env. variables (GET) CONTENT_TYPE, CONTENT_LENGTH,... SCRIPT_NAME=/cgi-bin/anniversaire.pl QUERY_STRING=mois=aout&jour=11

26 CGI - producing output Example in shell script: echo "content-type: text/html" echo echo "<!doctype html publi\"-//w3c/dtd html 3.2 final/en\">" echo "<html>" echo "<body>" echo "it is <b>" date "</b>" echo "</body>" echo "</html>" In other programming languages, you may use the std output to send the data out

27 Outline HTTP HTML forms Common Gateway Interface Servlets

28 Servlet definition A Servlet is a java program that extends the capabilities of a server it is a very generic, definition A HTTP Servlet is dedicated to HTTP server, and responds to HTTP requests Component based programming The Web server is already written in a generic way, and it implements the complete HTTP protocol For some specific URI, it redirects the request message to a servlet which is in charge of building the response Advantages The programmer is not concerned with implementing the HTTP protocol from scratch Different servlets can coexist in the same server

29 Servlet container The HTTP server must support containers a container is an extension of the server that allows the execution of external code

30 Servlet: basics The bytecode is on the server Every servlet is associated an URL ex: When the server receive a request with path /myservlet/prog, it calls the container to execute the associated servlet The servlet object is created the first time it is executed, then it is reused This means that it can maintain its state across different executions the servlet is executed by a thread (typically, a different thread for every request) pay attention to multi-threading issues! If there is an exception, the error code is sent back to the client by the container

31 Servlet: Java interface A servlet class extends javax.servlet.http.httpservlet It can redefine the method void service(servletrequest request, ServletResponse response); ServletRequest : String getmethod() return the HTTP method (e.g. GET or POST) String getparameter(string param) returns the value of the field param (present into a form) Enumeration getparameternames() returns all parameters names ServletResponse: void setcontenttype(string type) defines the MIME type of the response PrintWriter getwriter() returns an output stream that can be used to produce the HTML file

32 Servlet example The calculator void processrequest(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html;charset=utf-8"); try (PrintWriter out = response.getwriter()) { out.println("<!doctype html>");... out.println("method: " + request.getmethod() + "<br/>"); String q = request.getquerystring(); out.println("query: " + q + "<br>"); tring resp = ""; try { int result = compute(q); resp += "Result : " + result; } catch (ParseError ex) { resp = "Error! Operation unknown"; } out.println(resp + "<br/>"); out.println("</html>"); } }

33 Servlet example class ParseError extends Exception { }; protected int compute(string q) throws ParseError { if (q.contains("*")) { String x[] = q.split("\\*"); return Integer.parseInt(x[0]) * Integer.parseInt(x[1]); } else if (q.contains("+")) { String x[] = q.split("\\+"); return Integer.parseInt(x[0]) + Integer.parseInt(x[1]); } else if (q.contains("+")) { String x[] = q.split("\\-"); return Integer.parseInt(x[0]) - Integer.parseInt(x[1]); } else if (q.contains("/")) { String x[] = q.split("/"); return Integer.parseInt(x[0]) / Integer.parseInt(x[1]); } else throw new ParseError(); }

34 Persistence Let s try to add a counter variable, to see what happens across two invocations int counter = 0; void processrequest(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html;charset=utf-8"); try (PrintWriter out = response.getwriter()) {... tring resp = ""; try { int result = compute(q); counter++; resp += counter + ") Result : " + result; } catch (ParseError ex) { resp = "Error! Operation unknown"; } out.println(resp + "<br/>"); out.println("</html>"); } }

35 Example result At the third invocation:

36 Services service is called on every request normally, it automatically calls doget() for GET requests, dopost() for POST requests, etc. So, you can also decide to overload such functions instead of service void init(servletconfig c) : automatically called by the container during the loading/starting of the servlet object void destroy() automatically called by the container during the desctruction of the object

37 MIME types We can transfer any type of file back: we set the type with resp.setcontenttype("..."), with text/html image/gif video/mpeg audio/mp3 application/pdf application/octet-stream...

38 Transferring a file public class FichierServlet extends HttpServlet { public void service( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { resp.setcontenttype("application/octet-stream"); resp.setheader("content-disposition", "attachment;filename=monfichier.ext"); OutputStream os = resp.getoutputstream(); File f = new File("monfichier.ext"); byte [] content = new byte[f.length()]; FileInputStream fis = new FileInputStream(f); fis.read(content); fis.close(); os.write(content); } }

39 HTTP sessions There is no such a thing as a "session" in HTTP However, we can build something similar using a cookie, or a hidden field, etc. Java Servlet abstract this concept by providing the concept of "Session" On a request object, we can do HttpSession session = request.getsession(true) return the current session, or creates a new one is a session does not exist yet. HttpSession session = request.getsession(false) returns the current session, or null if it does not exist yet

40 HTTPSession methods void setattribute(string name, Object value) adds a pair (name, value) valid for this session Object getattribute(string name) return the value associated to the key "name", or null void removeattribute(string name) removes the pair corresponding to the name key Enumeration getattributenames() returns the names of all keys associated to this session void setmaxintervaltime(int seconds) sets the maximum duration of this session (MaxAge) long getcreationtime() / long getlastaccessedtime() returns the creation date / the last access date of this session as a long (convertible to Date)

41 Shared data It may be useful to share data among different servlets To do this, we can use a servlet context ServletContext ctx = getservletcontext() It is a dictionnary of (key,value) pairs, where values can be arbitrary jaba Objects Methods: void setattribute(string name, Object value) Object getattribute(string name) void removeattribute(string name) Enumeration getattributenames()

42 Deploy to install a servlet into a server, we need to prepare a war file Example: like jar, but for web applications jar cf app.war index.html WEB-INF/classes/* Every archive war must contain a WEB-INF/web.xml file that specifies the content and configures the servlets <web-app> <servlet> <servlet-name>helloservlet</servlet-name> <servlet-class>mypackage.helloservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>helloservlet</servlet-name> <url-pattern>/version/beta/hello</url-pattern> </servlet-mapping> </web-app> URL:

Session 8. Introduction to Servlets. Semester Project

Session 8. Introduction to Servlets. Semester Project Session 8 Introduction to Servlets 1 Semester Project Reverse engineer a version of the Oracle site You will be validating form fields with Ajax calls to a server You will use multiple formats for the

More information

Session 20 Data Sharing Session 20 Data Sharing & Cookies

Session 20 Data Sharing Session 20 Data Sharing & Cookies Session 20 Data Sharing & Cookies 1 Reading Shared scopes Java EE 7 Tutorial Section 17.3 Reference http state management www.ietf.org/rfc/rfc2965.txt Cookies Reading & Reference en.wikipedia.org/wiki/http_cookie

More information

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013

Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013 Java servlets CSCI 470: Web Science Keith Vertanen Copyright 2013 Overview Dynamic web content genera2on (thus far) CGI Web server modules Server- side scrip2ng e.g. PHP, ASP, JSP Custom web server Java

More information

Servlet Fudamentals. Celsina Bignoli

Servlet Fudamentals. Celsina Bignoli Servlet Fudamentals Celsina Bignoli bignolic@smccd.net What can you build with Servlets? Search Engines E-Commerce Applications Shopping Carts Product Catalogs Intranet Applications Groupware Applications:

More information

Session 9. Introduction to Servlets. Lecture Objectives

Session 9. Introduction to Servlets. Lecture Objectives Session 9 Introduction to Servlets Lecture Objectives Understand the foundations for client/server Web interactions Understand the servlet life cycle 2 10/11/2018 1 Reading & Reference Reading Use the

More information

Java Servlets. Preparing your System

Java Servlets. Preparing your System Java Servlets Preparing to develop servlets Writing and running an Hello World servlet Servlet Life Cycle Methods The Servlet API Loading and Testing Servlets Preparing your System Locate the file jakarta-tomcat-3.3a.zip

More information

Servlets by Example. Joe Howse 7 June 2011

Servlets by Example. Joe Howse 7 June 2011 Servlets by Example Joe Howse 7 June 2011 What is a servlet? A servlet is a Java application that receives HTTP requests as input and generates HTTP responses as output. As the name implies, it runs on

More information

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle

Enterprise Java Unit 1- Chapter 4 Prof. Sujata Rizal Servlet API and Lifecycle Introduction Now that the concept of servlet is in place, let s move one step further and understand the basic classes and interfaces that java provides to deal with servlets. Java provides a servlet Application

More information

Servlets and JSP (Java Server Pages)

Servlets and JSP (Java Server Pages) Servlets and JSP (Java Server Pages) XML HTTP CGI Web usability Last Week Nan Niu (nn@cs.toronto.edu) CSC309 -- Fall 2008 2 Servlets Generic Java2EE API for invoking and connecting to mini-servers (lightweight,

More information

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Enterprise Edition Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Beans Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 2 Java Bean POJO class : private Attributes public

More information

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests What is the servlet? Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently.

More information

JAVA SERVLET. Server-side Programming INTRODUCTION

JAVA SERVLET. Server-side Programming INTRODUCTION JAVA SERVLET Server-side Programming INTRODUCTION 1 AGENDA Introduction Java Servlet Web/Application Server Servlet Life Cycle Web Application Life Cycle Servlet API Writing Servlet Program Summary 2 INTRODUCTION

More information

Lecture 9a: Sessions and Cookies

Lecture 9a: Sessions and Cookies CS 655 / 441 Fall 2007 Lecture 9a: Sessions and Cookies 1 Review: Structure of a Web Application On every interchange between client and server, server must: Parse request. Look up session state and global

More information

Generating the Server Response: HTTP Response Headers

Generating the Server Response: HTTP Response Headers Generating the Server Response: HTTP Response Headers 1 Agenda Format of the HTTP response Setting response headers Understanding what response headers are good for Building Excel spread sheets Generating

More information

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC)

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC) Session 8 JavaBeans 1 Reading Reading & Reference Head First Chapter 3 (MVC) Reference JavaBeans Tutorialdocs.oracle.com/javase/tutorial/javabeans/ 2 2/27/2013 1 Lecture Objectives Understand how the Model/View/Controller

More information

AJP. CHAPTER 5: SERVLET -20 marks

AJP. CHAPTER 5: SERVLET -20 marks 1) Draw and explain the life cycle of servlet. (Explanation 3 Marks, Diagram -1 Marks) AJP CHAPTER 5: SERVLET -20 marks Ans : Three methods are central to the life cycle of a servlet. These are init( ),

More information

Servlets. An extension of a web server runs inside a servlet container

Servlets. An extension of a web server runs inside a servlet container Servlets What is a servlet? An extension of a web server runs inside a servlet container A Java class derived from the HttpServlet class A controller in webapplications captures requests can forward requests

More information

Get the cookies from the service request: Cookie[] HttpServletRequest.getCookies() Add a cookie to the service response:

Get the cookies from the service request: Cookie[] HttpServletRequest.getCookies() Add a cookie to the service response: Managing Cookies Cookies Cookies are a general mechanism which server side applications can use to both store and retrieve information on the client side Servers send cookies in the HTTP response and browsers

More information

UNIT-V. Web Servers: Tomcat Server Installation:

UNIT-V. Web Servers: Tomcat Server Installation: UNIT-V Web Servers: The Web server is meant for keeping Websites. It Stores and transmits web documents (files). It uses the HTTP protocol to connect to other computers and distribute information. Example:

More information

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON-

To follow the Deitel publishing program, sign-up now for the DEITEL BUZZ ON- Ordering Information: Advanced Java 2 Platform How to Program View the complete Table of Contents Read the Preface Download the Code Examples To view all the Deitel products and services available, visit

More information

SERVLETS INTERVIEW QUESTIONS

SERVLETS INTERVIEW QUESTIONS SERVLETS INTERVIEW QUESTIONS http://www.tutorialspoint.com/servlets/servlets_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Servlets Interview Questions have been designed especially

More information

&' () - #-& -#-!& 2 - % (3" 3 !!! + #%!%,)& ! "# * +,

&' () - #-& -#-!& 2 - % (3 3 !!! + #%!%,)& ! # * +, ! "# # $! " &' ()!"#$$&$'(!!! ($) * + #!,)& - #-& +"- #!(-& #& #$.//0& -#-!& #-$$!& 1+#& 2-2" (3" 3 * * +, - -! #.// HttpServlet $ Servlet 2 $"!4)$5 #& 5 5 6! 0 -.// # 1 7 8 5 9 2 35-4 2 3+ -4 2 36-4 $

More information

Topics. Advanced Java Programming. Quick HTTP refresher. Quick HTTP refresher. Web server can return:

Topics. Advanced Java Programming. Quick HTTP refresher. Quick HTTP refresher. Web server can return: Advanced Java Programming Servlets Chris Wong chw@it.uts.edu.au Orginal notes by Dr Wayne Brookes and Threading Copyright UTS 2008 Servlets Servlets-1 Copyright UTS 2008 Servlets Servlets-2 Quick HTTP

More information

CS105 Perl: Perl CGI. Nathan Clement 24 Feb 2014

CS105 Perl: Perl CGI. Nathan Clement 24 Feb 2014 CS105 Perl: Perl CGI Nathan Clement 24 Feb 2014 Agenda We will cover some CGI basics, including Perl-specific CGI What is CGI? Server Architecture GET vs POST Preserving State in CGI URL Rewriting, Hidden

More information

HTTP Protocol and Server-Side Basics

HTTP Protocol and Server-Side Basics HTTP Protocol and Server-Side Basics Web Programming Uta Priss ZELL, Ostfalia University 2013 Web Programming HTTP Protocol and Server-Side Basics Slide 1/26 Outline The HTTP protocol Environment Variables

More information

Advanced Web Technology

Advanced Web Technology Berne University of Applied Sciences Dr. E. Benoist Winter Term 2005-2006 Presentation 1 Presentation of the Course Part Java and the Web Servlet JSP and JSP Deployment The Model View Controler (Java Server

More information

COSC 2206 Internet Tools. The HTTP Protocol

COSC 2206 Internet Tools. The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol http://www.w3.org/protocols/ What is TCP/IP? TCP: Transmission Control Protocol IP: Internet Protocol These network protocols provide a standard method for sending

More information

Unit-4: Servlet Sessions:

Unit-4: Servlet Sessions: 4.1 What Is Session Tracking? Unit-4: Servlet Sessions: Session tracking is the capability of a server to maintain the current state of a single client s sequential requests. Session simply means a particular

More information

Forms, CGI. Cristian Bogdan 2D2052 / 2D1335 F5 1

Forms, CGI. Cristian Bogdan 2D2052 / 2D1335 F5 1 Forms, CGI Cristian Bogdan 2D2052 / 2D1335 F5 1 Objectives The basics of HTML forms How form content is submitted GET, POST Elements that you can have in forms Responding to forms Common Gateway Interface

More information

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web

4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web UNIT - 4 Servlet 4.1 The Life Cycle of a Servlet 4.2 The Java Servlet Development Kit 4.3 The Simple Servlet: Creating and compile servlet source code, start a web browser and request the servlet, example

More information

Lecture 7b: HTTP. Feb. 24, Internet and Intranet Protocols and Applications

Lecture 7b: HTTP. Feb. 24, Internet and Intranet Protocols and Applications Internet and Intranet Protocols and Applications Lecture 7b: HTTP Feb. 24, 2004 Arthur Goldberg Computer Science Department New York University artg@cs.nyu.edu WWW - HTTP/1.1 Web s application layer protocol

More information

Session 9. Data Sharing & Cookies. Reading & Reference. Reading. Reference http state management. Session 9 Data Sharing

Session 9. Data Sharing & Cookies. Reading & Reference. Reading. Reference http state management. Session 9 Data Sharing Session 9 Data Sharing & Cookies 1 Reading Reading & Reference Chapter 5, pages 185-204 Reference http state management www.ietf.org/rfc/rfc2109.txt?number=2109 2 3/1/2010 1 Lecture Objectives Understand

More information

Session 9. Deployment Descriptor Http. Reading and Reference. en.wikipedia.org/wiki/http. en.wikipedia.org/wiki/list_of_http_headers

Session 9. Deployment Descriptor Http. Reading and Reference. en.wikipedia.org/wiki/http. en.wikipedia.org/wiki/list_of_http_headers Session 9 Deployment Descriptor Http 1 Reading Reading and Reference en.wikipedia.org/wiki/http Reference http headers en.wikipedia.org/wiki/list_of_http_headers http status codes en.wikipedia.org/wiki/http_status_codes

More information

SSC - Web applications and development Introduction and Java Servlet (I)

SSC - Web applications and development Introduction and Java Servlet (I) SSC - Web applications and development Introduction and Java Servlet (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics What will we learn

More information

NETB 329 Lecture 13 Python CGI Programming

NETB 329 Lecture 13 Python CGI Programming NETB 329 Lecture 13 Python CGI Programming 1 of 83 What is CGI? The Common Gateway Interface, or CGI, is a set of standards that define how information is exchanged between the web server and a custom

More information

Forms, CGI. HTML forms. Form example. Form example...

Forms, CGI. HTML forms. Form example. Form example... Objectives HTML forms The basics of HTML forms How form content is submitted GET, POST Elements that you can have in forms Responding to forms CGI the Common Gateway Interface Later: Servlets Generation

More information

Component Based Software Engineering

Component Based Software Engineering Component Based Software Engineering Masato Suzuki School of Information Science Japan Advanced Institute of Science and Technology 1 Schedule Mar. 10 13:30-15:00 : 09. Introduction and basic concepts

More information

Forms, CGI. Objectives

Forms, CGI. Objectives Forms, CGI Objectives The basics of HTML forms How form content is submitted GET, POST Elements that you can have in forms Responding to forms Common Gateway Interface (CGI) Later: Servlets Generation

More information

INTERNET ENGINEERING. HTTP Protocol. Sadegh Aliakbary

INTERNET ENGINEERING. HTTP Protocol. Sadegh Aliakbary INTERNET ENGINEERING HTTP Protocol Sadegh Aliakbary Agenda HTTP Protocol HTTP Methods HTTP Request and Response State in HTTP Internet Engineering 2 HTTP HTTP Hyper-Text Transfer Protocol (HTTP) The fundamental

More information

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY

Chettinad College of Engineering and Technology CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND TECHNOLOGY UNIT IV SERVLETS 1. What is Servlets? a. Servlets are server side components that provide a powerful mechanism

More information

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes Session 8 Deployment Descriptor 1 Reading Reading and Reference en.wikipedia.org/wiki/http Reference http headers en.wikipedia.org/wiki/list_of_http_headers http status codes en.wikipedia.org/wiki/_status_codes

More information

3. WWW and HTTP. Fig.3.1 Architecture of WWW

3. WWW and HTTP. Fig.3.1 Architecture of WWW 3. WWW and HTTP The World Wide Web (WWW) is a repository of information linked together from points all over the world. The WWW has a unique combination of flexibility, portability, and user-friendly features

More information

Web, HTTP and Web Caching

Web, HTTP and Web Caching Web, HTTP and Web Caching 1 HTTP overview HTTP: hypertext transfer protocol Web s application layer protocol client/ model client: browser that requests, receives, displays Web objects : Web sends objects

More information

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature INTRODUCTION TO SERVLETS AND WEB CONTAINERS Actions in Accord with All the Laws of Nature Web server vs web container Most commercial web applications use Apache proven architecture and free license. Tomcat

More information

Session 10. Form Dataset. Lecture Objectives

Session 10. Form Dataset. Lecture Objectives Session 10 Form Dataset Lecture Objectives Understand the relationship between HTML form elements and parameters that are passed to the servlet, particularly the form dataset 2 10/1/2018 1 Example Form

More information

Servlets Basic Operations

Servlets Basic Operations Servlets Basic Operations Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu/~spring Overview Preparing to

More information

Web based Applications, Tomcat and Servlets - Lab 3 -

Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems Web based Applications, - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta The Basic Web Server CMPUT 391 Database Management

More information

GET /index.php HTTP/1.1 Host: User- agent: Mozilla/4.0

GET /index.php HTTP/1.1 Host:   User- agent: Mozilla/4.0 State management GET /index.php HTTP/1.1 Host: www.mtech.edu User- agent: Mozilla/4.0 HTTP/1.1 200 OK Date: Thu, 17 Nov 2011 15:54:10 GMT Server: Apache/2.2.16 (Debian) Content- Length: 285 Set- Cookie:

More information

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2 Java Servlets Adv. Web Technologies 1) Servlets (introduction) Emmanuel Benoist Fall Term 2016-17 Introduction HttpServlets Class HttpServletResponse HttpServletRequest Lifecycle Methods Session Handling

More information

CSC309: Introduction to Web Programming. Lecture 8

CSC309: Introduction to Web Programming. Lecture 8 CSC309: Introduction to Web Programming Lecture 8 Wael Aboulsaadat Front Layer Web Browser HTTP Request Get http://abc.ca/index.html Web (HTTP) Server HTTP Response .. How

More information

The HTTP Protocol HTTP

The HTTP Protocol HTTP The HTTP Protocol HTTP Copyright (c) 2013 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later

More information

USQ/CSC2406 Web Publishing

USQ/CSC2406 Web Publishing USQ/CSC2406 Web Publishing Lecture 4: HTML Forms, Server & CGI Scripts Tralvex (Rex) Yeap 19 December 2002 Outline Quick Review on Lecture 3 Topic 7: HTML Forms Topic 8: Server & CGI Scripts Class Activity

More information

Unit 4 - Servlet. Servlet. Advantage of Servlet

Unit 4 - Servlet. Servlet. Advantage of Servlet Servlet Servlet technology is used to create web application, resides at server side and generates dynamic web page. Before Servlet, CGI (Common Gateway Interface) was popular as a server-side programming

More information

Chapter 10 Servlets and Java Server Pages

Chapter 10 Servlets and Java Server Pages Chapter 10 Servlets and Java Server Pages 10.1 Overview of Servlets A servlet is a Java class designed to be run in the context of a special servlet container An instance of the servlet class is instantiated

More information

The Structure and Components of

The Structure and Components of Web Applications The Structure and Components of a JEE Web Application Sample Content garth@ggilmour.com The Structure t of a Web Application The application is deployed in a Web Archive A structured jar

More information

Computer Networks. Wenzhong Li. Nanjing University

Computer Networks. Wenzhong Li. Nanjing University Computer Networks Wenzhong Li Nanjing University 1 Chapter 8. Internet Applications Internet Applications Overview Domain Name Service (DNS) Electronic Mail File Transfer Protocol (FTP) WWW and HTTP Content

More information

Networking and Internet

Networking and Internet Today s Topic Lecture 13 Web Fundamentals Networking and Internet LAN Web pages Web resources Web client Web Server HTTP Protocol HTML & HTML Forms 1 2 LAN (Local Area Network) Networking and Internet

More information

HTTP and the Dynamic Web

HTTP and the Dynamic Web HTTP and the Dynamic Web How does the Web work? The canonical example in your Web browser Click here here is a Uniform Resource Locator (URL) http://www-cse.ucsd.edu It names the location of an object

More information

Java4570: Session Tracking using Cookies *

Java4570: Session Tracking using Cookies * OpenStax-CNX module: m48571 1 Java4570: Session Tracking using Cookies * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract

More information

Web Based Solutions. Gerry Seidman. IAM Consulting

Web Based Solutions. Gerry Seidman. IAM Consulting Web Based Solutions Gerry Seidman Internet Access Methods seidman@iamx.com http://www.iam-there.com 212-580-2700 IAM Consulting seidman@iamx.com http://www.iamx.com 212-580-2700 (c) IAM Consulting Corp.

More information

Introduction to Web applications with Java Technology 3- Servlets

Introduction to Web applications with Java Technology 3- Servlets Introduction to Web applications with Java Technology 3- Servlets Juan M. Gimeno, Josep M. Ribó January, 2008 Contents Introduction to web applications with Java technology 1. Introduction. 2. HTTP protocol

More information

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web

Introduction to Java Servlets. SWE 432 Design and Implementation of Software for the Web Introduction to Java Servlets James Baldo Jr. SWE 432 Design and Implementation of Software for the Web Web Applications A web application uses enabling technologies to 1. make web site contents dynamic

More information

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System

Database Applications Recitation 6. Project 3: CMUQFlix CMUQ s Movies Recommendation System 15-415 Database Applications Recitation 6 Project 3: CMUQFlix CMUQ s Movies Recommendation System 1 Project Objective 1. Set up a front-end website with PostgreSQL as the back-end 2. Allow users to login,

More information

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR

2. Follow the installation directions and install the server on ccc. 3. We will call the root of your installation as $TOMCAT_DIR Installing a Web Server 1. Install a sample web server, which supports Servlets/JSPs. A light weight web server is Apache Tomcat server. You can get the server from http://tomcat.apache.org/ 2. Follow

More information

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps. About the Tutorial Servlets provide a component-based, platform-independent method for building Webbased applications, without the performance limitations of CGI programs. Servlets have access to the entire

More information

HTML forms and the dynamic web

HTML forms and the dynamic web HTML forms and the dynamic web Antonio Lioy < lioy@polito.it > english version created by Marco D. Aime < m.aime@polito.it > Politecnico di Torino Dip. Automatica e Informatica timetable.html departure

More information

HTTP Reading: Section and COS 461: Computer Networks Spring 2013

HTTP Reading: Section and COS 461: Computer Networks Spring 2013 HTTP Reading: Section 9.1.2 and 9.4.3 COS 461: Computer Networks Spring 2013 1 Recap: Client-Server Communication Client sometimes on Initiates a request to the server when interested E.g., Web browser

More information

********************************************************************

******************************************************************** ******************************************************************** www.techfaq360.com SCWCD Mock Questions : Servlet ******************************************************************** Question No :1

More information

World Wide Web, etc.

World Wide Web, etc. World Wide Web, etc. Alex S. Raw data-packets wouldn t be much use to humans if there weren t many application level protocols, such as SMTP (for e-mail), HTTP & HTML (for www), etc. 1 The Web The following

More information

How does the Web work? HTTP and the Dynamic Web. Naming and URLs. In Action. HTTP in a Nutshell. Protocols. The canonical example in your Web browser

How does the Web work? HTTP and the Dynamic Web. Naming and URLs. In Action. HTTP in a Nutshell. Protocols. The canonical example in your Web browser How does the Web work? The canonical example in your Web browser and the Dynamic Web Click here here is a Uniform Resource Locator (URL) http://www-cse.ucsd.edu It names the location of an object on a

More information

JAVA SERVLET. Server-side Programming PROGRAMMING

JAVA SERVLET. Server-side Programming PROGRAMMING JAVA SERVLET Server-side Programming PROGRAMMING 1 AGENDA Passing Parameters Session Management Cookie Hidden Form URL Rewriting HttpSession 2 HTML FORMS Form data consists of name, value pairs Values

More information

Module 4: SERVLET and JSP

Module 4: SERVLET and JSP 1.What Is a Servlet? Module 4: SERVLET and JSP A servlet is a small Java program that runs within a Web server. Servlets receive and respond to requests from Web clients, usually across HTTP, the Hyper

More information

Hypertext Transport Protocol

Hypertext Transport Protocol Hypertext Transport Protocol HTTP Hypertext Transport Protocol Language of the Web protocol used for communication between web browsers and web servers TCP port 80 HTTP - URLs URL Uniform Resource Locator

More information

How to work with HTTP requests and responses

How to work with HTTP requests and responses How a web server processes static web pages Chapter 18 How to work with HTTP requests and responses How a web server processes dynamic web pages Slide 1 Slide 2 The components of a servlet/jsp application

More information

PYTHON CGI PROGRAMMING

PYTHON CGI PROGRAMMING PYTHON CGI PROGRAMMING http://www.tutorialspoint.com/python/python_cgi_programming.htm Copyright tutorialspoint.com The Common Gateway Interface, or CGI, is a set of standards that define how information

More information

JAVA SERVLET. Server-side Programming ADVANCED FEATURES

JAVA SERVLET. Server-side Programming ADVANCED FEATURES JAVA SERVLET Server-side Programming ADVANCED FEATURES 1 AGENDA RequestDispacher SendRedirect ServletConfig ServletContext ServletFilter SingleThreadedModel Events and Listeners Servlets & Database 2 REQUESTDISPATCHER

More information

Servlet Basics. Agenda

Servlet Basics. Agenda Servlet Basics 1 Agenda The basic structure of servlets A simple servlet that generates plain text A servlet that generates HTML Servlets and packages Some utilities that help build HTML The servlet life

More information

Introduction. This course Software Architecture with Java will discuss the following topics:

Introduction. This course Software Architecture with Java will discuss the following topics: Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD W HI TEPAPER www. p rogres s.com WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD In this whitepaper, we describe how to white label Progress Rollbase private cloud with your brand name by following a

More information

Web Engineering. Basic Technologies: Protocols and Web Servers. Husni

Web Engineering. Basic Technologies: Protocols and Web Servers. Husni Web Engineering Basic Technologies: Protocols and Web Servers Husni Husni@trunojoyo.ac.id Basic Web Technologies HTTP and HTML Web Servers Proxy Servers Content Delivery Networks Where we will be later

More information

Introduction to JSP and Servlets Training 5-days

Introduction to JSP and Servlets Training 5-days QWERTYUIOP{ Introduction to JSP and Servlets Training 5-days Introduction to JSP and Servlets training course develops skills in JavaServer Pages, or JSP, which is the standard means of authoring dynamic

More information

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar

Produced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology

More information

Module 3 Web Component

Module 3 Web Component Module 3 Component Model Objectives Describe the role of web components in a Java EE application Define the HTTP request-response model Compare Java servlets and JSP components Describe the basic session

More information

Outline of Lecture 5. Course Content. Objectives of Lecture 6 CGI and HTML Forms

Outline of Lecture 5. Course Content. Objectives of Lecture 6 CGI and HTML Forms Web-Based Information Systems Fall 2004 CMPUT 410: CGI and HTML Forms Dr. Osmar R. Zaïane University of Alberta Outline of Lecture 5 Introduction Poor Man s Animation Animation with Java Animation with

More information

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http? What are Servlets? Servlets1 Fatemeh Abbasinejad abbasine@cs.ucdavis.edu A program that runs on a web server acting as middle layer between requests coming from a web browser and databases or applications

More information

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003 Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

Web Programming. Based on Notes by D. Hollinger Also Java Network Programming and Distributed Computing, Chs.. 9,10 Also Online Java Tutorial, Sun.

Web Programming. Based on Notes by D. Hollinger Also Java Network Programming and Distributed Computing, Chs.. 9,10 Also Online Java Tutorial, Sun. Web Programming Based on Notes by D. Hollinger Also Java Network Programming and Distributed Computing, Chs.. 9,10 Also Online Java Tutorial, Sun. 1 World-Wide Wide Web (Tim Berners-Lee & Cailliau 92)

More information

Java E-Commerce Martin Cooke,

Java E-Commerce Martin Cooke, Java E-Commerce Martin Cooke, 2002 1 Plan The web tier: servlets life cycle Session-management TOMCAT & ANT Applet- communication The servlet life-cycle Notes based largely on Hunter & Crawford (2001)

More information

Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University

Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University 1 Objectives You will learn about Server-side web programming in Python Common Gateway Interface

More information

Advanced Internet Technology Lab # 4 Servlets

Advanced Internet Technology Lab # 4 Servlets Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Advanced Internet Technology Lab # 4 Servlets Eng. Doaa Abu Jabal Advanced Internet Technology Lab # 4 Servlets Objective:

More information

Using Java servlets to generate dynamic WAP content

Using Java servlets to generate dynamic WAP content C H A P T E R 2 4 Using Java servlets to generate dynamic WAP content 24.1 Generating dynamic WAP content 380 24.2 The role of the servlet 381 24.3 Generating output to WAP clients 382 24.4 Invoking a

More information

EDA095 HTTP. Pierre Nugues. March 30, Lund University

EDA095 HTTP. Pierre Nugues. March 30, Lund University EDA095 HTTP Pierre Nugues Lund University http://cs.lth.se/pierre_nugues/ March 30, 2017 Covers: Chapter 6, Java Network Programming, 4 rd ed., Elliotte Rusty Harold Pierre Nugues EDA095 HTTP March 30,

More information

Advance Java. Configuring and Getting Servlet Init Parameters per servlet

Advance Java. Configuring and Getting Servlet Init Parameters per servlet Advance Java Understanding Servlets What are Servlet Components? Web Application Architecture Two tier, three tier and N-tier Arch. Client and Server side Components and their relation Introduction to

More information

CIS 455 / 555: Internet and Web Systems

CIS 455 / 555: Internet and Web Systems 1 Background CIS 455 / 555: Internet and Web Systems Spring, 2010 Assignment 1: Web and Application Servers Milestone 1 due February 3, 2010 Milestone 2 due February 15, 2010 We are all familiar with how

More information

HTTP. HTTP HTML Parsing. Java

HTTP. HTTP HTML Parsing. Java ђѕђяѡъ ьэющ HTTP HTTP TCP/IP HTTP HTTP HTML Parsing HTTP HTTP GET < > web servers GET HTTP Port 80 HTTP GOOGLE HTML HTTP Port 80 HTTP URL (Uniform Resource Locator) HTTP URL http://www.cs.tau.ac.il:80/cs/index.html

More information

In servlet, form parsing is handled automatically. You call request.getparameter to get the value of a form parameter.

In servlet, form parsing is handled automatically. You call request.getparameter to get the value of a form parameter. In servlet, form parsing is handled automatically. You call request.getparameter to get the value of a form parameter. You can also call request.getparametervalues if the parameter appears more than once,

More information

Handout 31 Web Design & Development

Handout 31 Web Design & Development Lecture 31 Session Tracking We have discussed the importance of session tracking in the previous handout. Now, we ll discover the basic techniques used for session tracking. Cookies are one of these techniques

More information

Servlet and JSP Review

Servlet and JSP Review 2006 Marty Hall Servlet and JSP Review A Recap of the Basics 2 JSP, Servlet, Struts, JSF, AJAX, & Java 5 Training: http://courses.coreservlets.com J2EE Books from Sun Press: http://www.coreservlets.com

More information

Course Topics. The Three-Tier Architecture. Example 1: Airline reservations. IT360: Applied Database Systems. Introduction to PHP

Course Topics. The Three-Tier Architecture. Example 1: Airline reservations. IT360: Applied Database Systems. Introduction to PHP Course Topics IT360: Applied Database Systems Introduction to PHP Database design Relational model SQL Normalization PHP MySQL Database administration Transaction Processing Data Storage and Indexing The

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Java Server Pages (JSP) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442

More information