CISC 4700 L01 Network & Client-Server Programming Spring Harold, Chapter 7: URLConnections

Size: px
Start display at page:

Download "CISC 4700 L01 Network & Client-Server Programming Spring Harold, Chapter 7: URLConnections"

Transcription

1 CISC 4700 L01 Network & Client-Server Programming Spring 2016 Harold, Chapter 7: URLConnections

2 URLConnection: abstract class representing active connection to resource specified by URL. Provides more control over server interaction than URL class. Can inspect header sent by a server, and set client's header fields. Can send data to web server with HTTP request methods (POST, PUT, etc.). URLConnection is part of Java's protocol handler mechanism. A protocol handler separates details of processing a protocol from the other things that a web client might do. If browser encounters unknown scheme, it can download protocol handler for same and proceed. Abstract URLConnection classes in java.net package. Concrete subclasses in the sun.net package hierarchy. Many methods (including ctor) and fields in URLConnection are protected. URLConnection objects are not usually directly instantiated. They are generally created by runtime environment, as needed, using the forname() and newinstance() methods of java.lang.class.

3 Opening URLConnections Sequence? 1. Construct URL object. 2. Invoke its openconnection() method to retrieve URLConnection object for same. Configure the URLConnection. Read header fields. 1. Get input stream, read data. 2. Get output stream, write data. 3. Close connection. If defaults are acceptable, can skip some steps. 3

4 Constructor for URLConnection class: protected URLConnection(URL url); Unless subclassing to handle new kind of URL, create indirectly: try { URL u = new URL(" URLConnection uc = u.openconnection(); // read from URL... } catch (MalformedURLException ex) { System.err.println(ex); } catch (IOException ex) { System.err.println(ex); } If subclassing URLConnection must implement public abstract void connect() throws IOException; When URLConnection first constructed, it is unconnected. Use connect() to establish connection (usually via TCP sockets). Some methods getinputstream(), getcontent(), getheaderfield(),... requiring connection will call connect() if connection isn't already open. 4

5 Reading Data from a Server 1. Construct a URL object. 2. Invoke its openconnection() to get a URLConnection. Invoke URLConnection's getinputstream(). 1. Read from the input stream. Example: Differences between URL and URLConnection? URLConnection provides access to HTTP header. 1. URLConnection can configure request parameters sent to server. 2. URLConnection can write to and read from server. 5

6 Reading the Header Header has a lot of useful information: content type length charset expiration date modification date Can get this info easily with Java methods. 6

7 Retrieving Specific Header Fields public String getcontenttype() returns MIME media type of response body. Returns null if content type is unavailable. Assumes that web server isn't lying. If content type is text/*, header may also contain charset info; return value of getcontenttype() will contain this as well. See rceviewer.java for program to download web page with correct charset. public int getcontentlength() tells how many bytes in content; if no Content-length header, it returns -1. If resource length exceeds , returns -1. In this case, use public int getcontentlengthlong()instead. Example: Download a binary file. Previously, used openstream() to download text file, reading until server closed connection. Unsafe for binary file, since server doesn't always close server exactly when data is finished. More reliable: Use getcontentlength() to find file length. See 7

8 public String getcontentencoding(): If content is unencoded, returns null. x-gzip: most commonly used encoding on the Web. public long getdate(): Returns long (number of milliseconds since Epoch), or 0 if no Date: field. public long getexpiration() public long getlastmodified() Example: Read URLs from command line, determine content type, length, encoding, and dates (modification, expiration, current). 8

9 Retrieving arbitrary header fields Since there's no limit to the variety of header fields... public String getheaderfield(string name) returns value of named header field (not case-sensitive, no closing colon). Returns null if no such field. If you want a numeric value, convert String to long or int. Example: Get value of the Content-Type field via String contenttype = uc.getheaderfield("content-type"); public String getheaderfieldkey(int n) returns key of nth header field. public String getheaderfield=(int n) returns value of nth header field. Example: Print out entire HTTP header. va 9

10 public long getheaderfielddate(string name, long default) retrieves header filed specified by name argument and tries to convert it to a long specifying number of milliseconds since Epoch. Internally, it uses parsedate() from java.util.date. If parsedate() doesn't understand the date or if getheaderfielddate() can't find requested header field, it returns the default argument. public int getheaderfieldint(string name, int default) retrieves value of header field specified by name argument and tries to convert it to an int. If it fails, returns default argument. Example: int contentlength = uc.getheaderfieldint("content-length", -1); 10

11 Caches Browsers cache web resources upon first encounter, reloading from cache when needed, unless cached version is stale. Pages accessed via GET over HTTP should be cached. Pages accessed via PUT should not be cached. This can be adjusted, depending on HTTP header contents: Expires gives expiration date Cache-control offers fine-grained control Last-modified ETag unique resource ID that changes when the resource does. Simple Java class for parsing and querying Cache-control headers If resource's representation is available in cache... if (expiry date hasn't arrived) use cached value else { check server with HEAD if (resource hasn't changed) use cached value else GET resource } 11

12 Web Cache for Java Default: Java caches nothing To install system-wide cache that URL class will use, you need concrete subclasses of RepsonseCache, CacheRequest, CacheResponse. Install your subclass of ResponseCache that works with your subclass of CacheResponse by passing it to RepsonseCache.setDefault(). JVM only supports a single shared cache. When system tries to load new URL, it first looks in cache. If present, URLConnection doesn't need to connect to remote server. Otherwise, protocol handler will download it, putting response into cache for next time. Storing/retrieving data from cache: public abstract CacheResponse get(url uri, String reuqestmethod, Map<String, List<String>> requestheaders) throws IOException; public abstract CacheRequest put(url uri, URLConnection connection)throws IOException; CacheRequest: abstract class with getbody() and abort() methods Example of concrete subclass of CacheRequest at t.java 12

13 get() method in ResponseCache retrieves data and headers from cache, returning them wrapped in a CacheResponse object. (If desired URI isn't in cache, returns null.) CacheResponse has two abstract methods: getheaders(), getbody(). Here we have a CacheResponse subclass tied to a SimpleCache and a CacheControl. Shared references pass data from request class to response class. onse.java Here we have a simple ResponseCache subclass that stores and retrieves cached values as requested. 13

14 Configuring the Connection URLConnection class has seven protected instance fields: url, doinput, dooutput, allowuserinteraction, usecaches, ifmodifiedsince, connected Accessed and modified via obvious getters and setters. Can only modify before URLConnection is connected. There are also getter/setter methods defining default behavior for all instances of URLConnection: getdefaultusecaches(), setdefaultusecaches(), getdefaultallowuserinteraction(), setdefaultallowuserinteraction(), getfilenamemap(), setfilenamemap() These can be invoked at any time. Moderately straightforward. Example: Program that prints default value of ifmodifiedsince, sets its value to 24 hours ago, prints new value. If doc has been modified in last 24 hours, downloads and displays. 14

15 Can disable the cache (forcing a reload), by uc.setusecaches(false); We can't access usecaches directly in client code; it's protected. Can query and modify connect and read timeout values, using the obvious getters and setters. 15

16 Configuring the Client Request HTTP Header HTTP client sends server a request line and a header. Header Chrome sends for is Request URL: Request Method:GET Status Code:304 Not Modified Accept:text/html,application/xhtml+xml,application/xml;q=0.9,im age/webp,*/*;q=0.8 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8,de;q=0.6 Cache-Control:max-age=0 Connection:keep-alive Cookie: gads=id=7e17eed5cbf9389f:t= :s=alni_mz1wqsuqk 1DlYzGXzWrZ0aC4KuBQg; wt3_sid=%3b ; et cetera Host: If-Modified-Since:Sun, 12 Jan :04:39 GMT If-None-Match:"db1-4efcaa1906ef2" User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/ (KHTML, like Gecko) Chrome/ Safari/

17 Web server can user this information to do stuff: alter info and layout to fit web client get/set cookies authenticate cookies... Can add more headers to HTTP header using public void setrequestproperty(string name, String value) before opening connection. A property may have multiple values. Example: A cookie is a collection of (name, value) pairs, e.g., Cookie: username=bovik; password=go+tartans;session=42 Adding this to a connection: uc.setrequestproperty("cookie", "username=bovik; password=go+tartans;session=42"); Adding a new property: public void addrequestproperty(string name, String value); 17

18 No fixed list of legal headers. Servers can ignore headers they don't recognize. HTTP mildly restricts header name/value content: For instance, no whitespace or line breaks. Java only enforces "no line breaks". Easy to create malformed headers in Java. How a server reacts to same? Unpredictable. To inspect headers in a URLConnection: public String getrequestproperty(string name); Can get all request properties for a connection: public Map<String,List<String>> getrequestproperties(); 18

19 Writing Data to a Server... submitting form info using POST, GET... uploading file using PUT To get an output stream, use public OutputStream getoutputstream(); But first, call setdooutput(true); For an http URL, this changes request method from GET to POST. Remember... GET: only for safe operations POST: for unsafe operations Once you have OutputStream, buffer it by chaining it to BufferredOutputStream, BufferredWriter, DataOutputStream, OutputStreamWriter, or whatever's convenient. Sending data with POST is similar to GET, except must setdooutput(true); use getoutputstream()to obtain stream to write query, rather than attaching it to URL. 19

20 Java buffers data written onto output stream until closed. This allows Java to determine content length. [Use telnet to demo a complete transaction.] Example: FormPoster uses URLConnection class and QueryString class (Chapter 5) to post form data: Constructor sets the URL. add() builds query string. post() actually sends data to server. See for details. 20

21 Security Considerations for URLConnections URLConnection objects: subject to usual security restrictions: making network connections reading or writing files etc. Ex: A URLConnection can be created by untrusted applet iff URLConnection points to host from which applet came. Details can be tricky. Ex: A jar URL pointing into applet's own jar file: okay. A jar URL pointing into local hard rive: not okay. Is it okay to connect to a URL? public Permission getpermission() throws IOException; Returns java.security.permission objet specifying permission needed to connect to the URL. Returns null if no permission is needed (e.g., no security manager in place). Subclasses of URLConnection return different subclasses of java.security.permission, such as java.net.socketpermission. 21

22 Guessing MIME Media Types Can't depend on protocols and servers using standard MIME types. URLConnection has two static methods to help figure out MIME type public static String guesscontenttypefromname(string name); Uses content-types.properties (usually in jre/lib) /etc/mailcap (on Unix) public static string guesscontenttypefromstream(inputstream in); Looks in first few (at most 16) bytes of data in the stream (akin to Unix file). Input stream must support marking. Less reliable than guesscontenttypefromname(), e.g., XML doc beginning with comment is mislabeled as HTML. 22

23 HttpURLConnection Class Abstract subclass of URLConnection. Provides additional methods when working with http URLs: get/set request method decide whether to follow redirects get response code, msg determine whether proxy server is being used overrides getpermission() Can't directly create instances of same. Do something akin to URL u = new URL(" URLConnection uc = u.openconnection(); HttpURLConnection http = (HttpURLConnection) uc; 23

24 Request method Most common request method is GET. Other request methods: POST, HEAD, PUT, DELETE, OPTIONS, TRACE By default HttpURLConnection uses GET. Change via public void setrequestmethod(string method) throws ProtocolException where method can be any of GET, POST, HEAD, PUT, DELETE, OPTIONS, TRACE May need to perform other actions, as well. Ex: POST needs a Content-length header. Some servers (e.g., WebDAV) support additional non-standard request methods, not supported by Java. GET: Previously discussed POST: Previously discussed 24

25 HEAD Behaves much like GET. Only returns HTTP header, not the file. Ex: Get the time a URL was last changed DELETE Not supported by all servers. Response is implementation dependent (actual removal vs. move to trash). PUT Store file on web server; often used by web-aware text editors. User must know actual directory structure. Authentication needed. OPTIONS What options are supported for a URL? TRACE Echoes HTTP header server received from client. Useful to see whether a proxy server is intercepting. 25

26 Disconnecting from the Server HTTP 1.1 supports persistent connections over a fixed TCP socket. If Keep-Alive is used, server won't immediately close connection upon sending last byte of data to client. Server will time out after (say) 5 seconds of inactivity. Preferable to explicitly close connection when done. HttpURLConnection transparently supports Keep-Alive unless explicitly disabled. When done talking to host public abstract void disconnect() closes any open streams. NB: Closing all open streams does not close socket and disconnect. 26

27 Handling Server Responses First line of server response: numeric code and explanatory msg. Obtain via public int getresponsecode() throws IOException; and public String getresponsemessage() throws IOException; HttpURLConnection contains 36 named constants, e.g., HttpURLConnection.OK HttpURLConnection.NOT_FOUND Ex: SourceViewer program including the response code and msg, see Note that there's no method to specifically return HTTP version, so we fake it (as HTTP/1.x). However, uc.getheaderfield(0) returns entire first HTTP request line: HTTP/ OK 27

28 Error Conditions The server can be configured to sendx alternative error pages,giving more info than 404 Not found, see for an example. Can use public InputStream geterrorstream() to return InputStream containing such a page (or null, if not found). Generally inside catch block after getinputstream() fails. Ex: Yet another SourceViewer, reading from error stream if input stream fails. Redirects By default, HttpURLConnection follows redirects. "Globally" configurable via static methods public static boolean getfollowredirects(); public static void setfollowredirects(boolean follow); and locally (instance-by-instance) via methods public boolean getinstancefollowredirects(); public static void setinstancefollowredirects(boolean follow); Proxies Is this HttpURLConnection going through a proxy server? public abstract boolean usingproxy(); 28

29 Streaming Mode HTTP Catch-22: Need to write Content-length header before the body Only know the length after we count number of bytes in body Java caches everything you write until OutputStream is closed. Good for small responses. Bad for large responses. If you know the size of the response, can do long length =...; response.setheader("content-length", String.valueOf(length)); If not, use chunked transfer encoding, in which request body is sent in multiple pieces, each with its own content length. Enable same via public void setchunkedstramingmode(int chunklength); HTTP sent out by Java will be somewhat different, but this is transparent to the Java programmer if using URLConnection class (rather than raw sockets). It does get in the way of authentication and redirection. If you know size of request data in advance, can optimize, via public void setfixedlengthstreamingmode(int contentlength); public void setfixedlengthstreamingmode(long contentlength); See text for some caveats. 29

Writing a Protocol Handler

Writing a Protocol Handler Writing a Protocol Handler A URL object uses a protocol handler to establish a connection with a server and perform whatever protocol is necessary to retrieve data. For example, an HTTP protocol handler

More information

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000)

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) armahmood786@yahoo.com alphasecure@gmail.com alphapeeler.sf.net/pubkeys/pkey.htm http://alphapeeler.sourceforge.net pk.linkedin.com/in/armahmood

More information

Networking and Security

Networking and Security Chapter 03 Networking and Security Mr. Nilesh Vishwasrao Patil Government Polytechnic Ahmednagar Socket Network socket is an endpoint of an interprocess communication flow across a computer network. Sockets

More information

TCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket

TCP connections. Fundamentals of Internet Connections Objectives. Connect to an Echo port. java.net.socket Objectives TCP connections To understand programming of clients that connect to servers via TCP To understand the basics of programming of servers that accept TCP connections To practice programming of

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

C24: Web API: Passing Arguments and Parsing Returns

C24: Web API: Passing Arguments and Parsing Returns CISC 3120 C24: Web API: Passing Arguments and Parsing Returns Hui Chen Department of Computer & Information Science CUNY Brooklyn College 5/7/2018 CUNY Brooklyn College 1 Outline Parsing arguments/data

More information

The HTTP protocol. Fulvio Corno, Dario Bonino. 08/10/09 http 1

The HTTP protocol. Fulvio Corno, Dario Bonino. 08/10/09 http 1 The HTTP protocol Fulvio Corno, Dario Bonino 08/10/09 http 1 What is HTTP? HTTP stands for Hypertext Transfer Protocol It is the network protocol used to delivery virtually all data over the WWW: Images

More information

EDA095 URLConnections

EDA095 URLConnections EDA095 URLConnections Pierre Nugues Lund University http://cs.lth.se/home/pierre_nugues/ March 30, 2017 Covers: Chapter 7, Java Network Programming, 4 th ed., Elliotte Rusty Harold Pierre Nugues EDA095

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

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

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

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

CSE 333 Lecture HTTP

CSE 333 Lecture HTTP CSE 333 Lecture 19 -- HTTP Hal Perkins Department of Computer Science & Engineering University of Washington Administrivia Server-side programming exercise due Wed. morning HW4 due a week later - How s

More information

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment

Requirements. PA4: Multi-thread File Downloader Page 1. Assignment PA4: Multi-thread File Downloader Page 1 Assignment What to Submit Write a program that downloads a file from the Internet using multiple threads. The application has a Graphical Interface written in JavaFX,

More information

Web Server Project. Tom Kelliher, CS points, due May 4, 2011

Web Server Project. Tom Kelliher, CS points, due May 4, 2011 Web Server Project Tom Kelliher, CS 325 100 points, due May 4, 2011 Introduction (From Kurose & Ross, 4th ed.) In this project you will develop a Web server in two steps. In the end, you will have built

More information

20.5. urllib Open arbitrary resources by URL

20.5. urllib Open arbitrary resources by URL 1 of 9 01/25/2012 11:19 AM 20.5. urllib Open arbitrary resources by URL Note: The urllib module has been split into parts and renamed in Python 3.0 to urllib.request, urllib.parse, and urllib.error. The

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

Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection)

Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection) Java.net Package and Classes(Url, UrlConnection, HttpUrlConnection) Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in

More information

CSE 333 Lecture HTTP

CSE 333 Lecture HTTP CSE 333 Lecture 19 -- HTTP Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia HW4 due a week from Thursday - How s it look? Today: http; finish networking/web

More information

Advanced Java Programming. Networking

Advanced Java Programming. Networking Advanced Java Programming Networking Eran Werner and Ohad Barzilay Tel-Aviv University Advanced Java Programming, Spring 2006 1 Overview of networking Advanced Java Programming, Spring 2006 2 TCP/IP protocol

More information

AJP: Chapter 2 Networking: 18 marks

AJP: Chapter 2 Networking: 18 marks AJP: Chapter 2 Networking: 18 marks Syllabus 2.1 Basics Socket overview, client/server, reserved sockets, proxy servers, internet addressing. 2.2 Java & the Net The networking classes & interfaces 2.3

More information

Introduction to Java.net Package. CGS 3416 Java for Non Majors

Introduction to Java.net Package. CGS 3416 Java for Non Majors Introduction to Java.net Package CGS 3416 Java for Non Majors 1 Package Overview The package java.net contains class and interfaces that provide powerful infrastructure for implementing networking applications.

More information

1-1. Switching Networks (Fall 2010) EE 586 Communication and. September Lecture 10

1-1. Switching Networks (Fall 2010) EE 586 Communication and. September Lecture 10 EE 586 Communication and Switching Networks (Fall 2010) Lecture 10 September 17 2010 1-1 Announcement Send me your group and get group ID HW3 (short) out on Monday Personal leave for next two weeks No

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

Computer Networks - A Simple HTTP proxy -

Computer Networks - A Simple HTTP proxy - Computer Networks - A Simple HTTP proxy - Objectives The intent of this assignment is to help you gain a thorough understanding of: The interaction between browsers and web servers The basics of the HTTP

More information

CS193j, Stanford Handout #26. Files and Streams

CS193j, Stanford Handout #26. Files and Streams CS193j, Stanford Handout #26 Summer, 2003 Manu Kumar Files and Streams File The File class represents a file or directory in the file system. It provides platform independent ways to test file attributes,

More information

CMSC 332 Computer Networking Web and FTP

CMSC 332 Computer Networking Web and FTP CMSC 332 Computer Networking Web and FTP Professor Szajda CMSC 332: Computer Networks Project The first project has been posted on the website. Check the web page for the link! Due 2/2! Enter strings into

More information

The realtime web: HTTP/1.1 to WebSocket, SPDY and beyond. Guillermo QCon. November 2012.

The realtime web: HTTP/1.1 to WebSocket, SPDY and beyond. Guillermo QCon. November 2012. The realtime web: HTTP/1.1 to WebSocket, SPDY and beyond Guillermo Rauch @ QCon. November 2012. Guillermo. CTO and co-founder at LearnBoost. Creator of socket.io and engine.io. @rauchg on twitter http://devthought.com

More information

HyperText Transfer Protocol

HyperText Transfer Protocol Outline Introduce Socket Programming Domain Name Service (DNS) Standard Application-level Protocols email (SMTP) HTTP HyperText Transfer Protocol Defintitions A web page consists of a base HTML-file which

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

Info 408 Distributed Applications programming 2 nd semester of 2017/2018 Credits: 5 Lecturer: Dr. Antoun Yaacoub

Info 408 Distributed Applications programming 2 nd semester of 2017/2018 Credits: 5 Lecturer: Dr. Antoun Yaacoub Lebanese University Faculty of Science I Master 1 degree Computer Science Info 408 Distributed Applications programming 2 nd semester of 2017/2018 Credits: 5 Lecturer: Dr. Antoun Yaacoub Starting Network

More information

The security mechanisms of Java

The security mechanisms of Java The security mechanisms of Java Carlo U. Nicola, SGI FHNW With extracts from publications of : Sun developers' center documentation; David A. Wheeler, UC Berkeley; Klaus Ostermann, TH-Darmstadt. Topics

More information

Lab 2. All datagrams related to favicon.ico had been ignored. Diagram 1. Diagram 2

Lab 2. All datagrams related to favicon.ico had been ignored. Diagram 1. Diagram 2 Lab 2 All datagrams related to favicon.ico had been ignored. Diagram 1 Diagram 2 1. Is your browser running HTTP version 1.0 or 1.1? What version of HTTP is the server running? According to the diagram

More information

Internet Protocol. Chapter 5 Protocol Layering. Juho Kim Graduate School of Information & Technology Sogang University

Internet Protocol. Chapter 5 Protocol Layering. Juho Kim Graduate School of Information & Technology Sogang University Internet Protocol Chapter 5 Protocol Layering Juho Kim Graduate School of Information & Technology Sogang University Department of of Computer Science and and Engineering, Sogang University Page 1 CAD

More information

CH -7 RESPONSE HEADERS

CH -7 RESPONSE HEADERS CH -7 RESPONSE HEADERS. SETTING RESPONSE HEADERS FROM SERVLET setheader(string Name, String Value) This method sets the response header with the designated name to the given value. There are two specialized

More information

BIG-IP Access Policy Manager : Portal Access. Version 13.0

BIG-IP Access Policy Manager : Portal Access. Version 13.0 BIG-IP Access Policy Manager : Portal Access Version 13.0 Table of Contents Table of Contents Overview of Portal Access...7 Overview: What is portal access?...7 About portal access configuration elements...

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

Web. Computer Organization 4/16/2015. CSC252 - Spring Web and HTTP. URLs. Kai Shen

Web. Computer Organization 4/16/2015. CSC252 - Spring Web and HTTP. URLs. Kai Shen Web and HTTP Web Kai Shen Web: the Internet application for distributed publishing and viewing of content Client/server model server: hosts published content and sends the content upon request client:

More information

BIG-IP Access Policy Manager : Portal Access. Version 12.1

BIG-IP Access Policy Manager : Portal Access. Version 12.1 BIG-IP Access Policy Manager : Portal Access Version 12.1 Table of Contents Table of Contents Overview of Portal Access...7 Overview: What is portal access?...7 About portal access configuration elements...7

More information

Pemrograman Jaringan Web Client Access PTIIK

Pemrograman Jaringan Web Client Access PTIIK Pemrograman Jaringan Web Client Access PTIIK - 2012 In This Chapter You'll learn how to : Download web pages Authenticate to a remote HTTP server Submit form data Handle errors Communicate with protocols

More information

Socket programming. Complement for the programming assignment INFO-0010

Socket programming. Complement for the programming assignment INFO-0010 Socket programming Complement for the programming assignment INFO-0010 Outline Socket definition Briefing on the Socket API A simple example in Java Multi-threading and Synchronization Example : HTTP protocol

More information

Files and Streams

Files and Streams Files and Streams 4-18-2006 1 Opening Discussion Do you have any questions about the quiz? What did we talk about last class? Do you have any questions about the assignment? What are files and why are

More information

Distributed Systems COMP 212. Lecture 8 Othon Michail

Distributed Systems COMP 212. Lecture 8 Othon Michail Distributed Systems COMP 212 Lecture 8 Othon Michail HTTP Protocol Hypertext Transfer Protocol Used to transmit resources on the WWW HTML files, image files, query results, Identified by Uniform Resource

More information

Web History. Systemprogrammering 2006 Föreläsning 9 Web Services. Internet Hosts. Web History (cont) 1945: 1989: Topics 1990:

Web History. Systemprogrammering 2006 Föreläsning 9 Web Services. Internet Hosts. Web History (cont) 1945: 1989: Topics 1990: Systemprogrammering 2006 Föreläsning 9 Web Services Topics HTTP Serving static content Serving dynamic content 1945: 1989: Web History Vannevar Bush, As we may think, Atlantic Monthly, July, 1945. Describes

More information

Java Support for developing TCP Network Based Programs

Java Support for developing TCP Network Based Programs Java Support for developing TCP Network Based Programs 1 How to Write a Network Based Program (In Java) As mentioned, we will use the TCP Transport Protocol. To communicate over TCP, a client program and

More information

Giving credit where credit is due

Giving credit where credit is due CSCE 230J Computer Organization Web Services Dr. Steve Goddard goddard@cse.unl.edu Giving credit where credit is due Most of slides for this lecture are based on slides created by Drs. Bryant and O Hallaron,

More information

Socket 101 Excerpt from Network Programming

Socket 101 Excerpt from Network Programming Socket 101 Excerpt from Network Programming EDA095 Nätverksprogrammering Originals by Roger Henriksson Computer Science Lund University Java I/O Streams Stream (swe. Ström) - A stream is a sequential ordering

More information

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng.

CS 355. Computer Networking. Wei Lu, Ph.D., P.Eng. CS 355 Computer Networking Wei Lu, Ph.D., P.Eng. Chapter 2: Application Layer Overview: Principles of network applications? Introduction to Wireshark Web and HTTP FTP Electronic Mail SMTP, POP3, IMAP DNS

More information

09-1. CSE 143 Java GREAT IDEAS IN COMPUTER SCIENCE. Overview. Data Representation. Representation of Primitive Java Types. Input and Output.

09-1. CSE 143 Java GREAT IDEAS IN COMPUTER SCIENCE. Overview. Data Representation. Representation of Primitive Java Types. Input and Output. CSE 143 Java Streams Reading: 19.1, Appendix A.2 GREAT IDEAS IN COMPUTER SCIENCE REPRESENTATION VS. RENDERING 4/28/2002 (c) University of Washington 09-1 4/28/2002 (c) University of Washington 09-2 Topics

More information

PIC 20A Streams and I/O

PIC 20A Streams and I/O PIC 20A Streams and I/O Ernest Ryu UCLA Mathematics Last edited: December 7, 2017 Why streams? Often, you want to do I/O without paying attention to where you are reading from or writing to. You can read

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

Zero Latency HTTP The comet Technique

Zero Latency HTTP The comet Technique Zero Latency HTTP The comet Technique Filip Hanik SpringSource Inc Keystone, Colorado, 2008 Slide 1 Who am I bla bla fhanik@apache.org Tomcat Committer / ASF member Co-designed the Comet implementation

More information

ECS-503 Object Oriented Techniques

ECS-503 Object Oriented Techniques UNIT-4 Part-2 ECS-503 Object Oriented Techniques CHAPTER 16 String Handling Java implements strings as objects of type String. Implementing strings as built-in objects allows Java to provide a full complement

More information

Lab 2: File Input and Output

Lab 2: File Input and Output Lab 2: File Input and Output This lab introduces how to handle files as both input and output. We re coming back to Tracery (which you implemented in Lab 1) with this assignment but instead of always reading

More information

COMPUTER NETWORKS AND COMMUNICATION PROTOCOLS. Web Access: HTTP Mehmet KORKMAZ

COMPUTER NETWORKS AND COMMUNICATION PROTOCOLS. Web Access: HTTP Mehmet KORKMAZ COMPUTER NETWORKS AND COMMUNICATION PROTOCOLS Web Access: HTTP 16501018 Mehmet KORKMAZ World Wide Web What is WWW? WWW = World Wide Web = Web!= Internet Internet is a global system of interconnected computer

More information

Web Programming 4) PHP and the Web

Web Programming 4) PHP and the Web Web Programming 4) PHP and the Web Emmanuel Benoist Fall Term 2013-14 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 PHP a language for Web applications Presentation

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

Lecture 11.1 I/O Streams

Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 1 OBJECT ORIENTED PROGRAMMING Lecture 11.1 I/O Streams 21/04/2014 Ebtsam AbdelHakam 2 Outline I/O Basics Streams Reading characters and string 21/04/2014 Ebtsam AbdelHakam

More information

CS2 Advanced Programming in Java note 8

CS2 Advanced Programming in Java note 8 CS2 Advanced Programming in Java note 8 Java and the Internet One of the reasons Java is so popular is because of the exciting possibilities it offers for exploiting the power of the Internet. On the one

More information

Detects Potential Problems. Customizable Data Columns. Support for International Characters

Detects Potential Problems. Customizable Data Columns. Support for International Characters Home Buy Download Support Company Blog Features Home Features HttpWatch Home Overview Features Compare Editions New in Version 9.x Awards and Reviews Download Pricing Our Customers Who is using it? What

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

Assignment, part 2. Statement and concepts INFO-0010

Assignment, part 2. Statement and concepts INFO-0010 Assignment, part 2 Statement and concepts INFO-0010 Outline Statement Implementation of concepts Objective Mastermind game using HTTP GET and HTTP POST methods The platform Architecture Root page ("/")

More information

REST Easy with Infrared360

REST Easy with Infrared360 REST Easy with Infrared360 A discussion on HTTP-based RESTful Web Services and how to use them in Infrared360 What is REST? REST stands for Representational State Transfer, which is an architectural style

More information

OBJECT ORIENTED PROGRAMMING

OBJECT ORIENTED PROGRAMMING 1 OBJECT ORIENTED PROGRAMMING Lecture 14 Networking Basics Outline 2 Networking Basics Socket IP Address DNS Client/Server Networking Class & Interface URL Demonstrating URL Networking 3 Java is practically

More information

HTTP Server Application

HTTP Server Application 1 Introduction You are to design and develop a concurrent TCP server that implements the HTTP protocol in the form of what is commonly called a web server. This server will accept and process HEAD and

More information

Elevate Web Builder Modules Manual

Elevate Web Builder Modules Manual Table of Contents Elevate Web Builder Modules Manual Table Of Contents Chapter 1 - Getting Started 1 1.1 Creating a Module 1 1.2 Handling Requests 3 1.3 Custom DataSet Modules 8 Chapter 2 - Component Reference

More information

CS193i Handout #18. HTTP Part 5

CS193i Handout #18. HTTP Part 5 HTTP Part 5 HTTP Under The Hood Write a little echo server that listens for HTTP requests on port 8181, and then just echoes it back, so we can see the details for the browser request... Echo Server Code

More information

Internet Connectivity with

Internet Connectivity with Internet Connectivity with Introduction The purpose of this workshop is to help you g et acquainted with the basics of internet connectivity by leveraging ARM mbed tools. If you are not already familiar

More information

CMPE 151: Network Administration. Servers

CMPE 151: Network Administration. Servers CMPE 151: Network Administration Servers Announcements Unix shell+emacs tutorial. Basic Servers Telnet/Finger FTP Web SSH NNTP Let s look at the underlying protocols. Client-Server Model Request Response

More information

Input, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003

Input, Output and Exceptions. COMS W1007 Introduction to Computer Science. Christopher Conway 24 June 2003 Input, Output and Exceptions COMS W1007 Introduction to Computer Science Christopher Conway 24 June 2003 Input vs. Output We define input and output from the perspective of the programmer. Input is data

More information

HTTPS File Transfer. Specification

HTTPS File Transfer. Specification HTTPS File Transfer Specification Version 1.4 5-Apr-2017 Date Version Description 30-Aug-2010 1.0 Original Version 30-Jun-2011 1.1 Added FAQ 29-Jun-2015 1.2 ilink administration added 1-Sep-2015 1.3 Updated

More information

COMP 321: Introduction to Computer Systems

COMP 321: Introduction to Computer Systems Assigned: 3/29/18, Due: 4/19/18 Important: This project may be done individually or in pairs. Be sure to carefully read the course policies for assignments (including the honor code policy) on the assignments

More information

COMP-202 Unit 9: Exceptions

COMP-202 Unit 9: Exceptions COMP-202 Unit 9: Exceptions Announcements - Assignment 4: due Monday April 16th - Assignment 4: tutorial - Final exam tutorial next week 2 Exceptions An exception is an object that describes an unusual

More information

Proxying. Why and How. Alon Altman. Haifa Linux Club. Proxying p.1/24

Proxying. Why and How. Alon Altman. Haifa Linux Club. Proxying p.1/24 Proxying p.1/24 Proxying Why and How Alon Altman alon@haifux.org Haifa Linux Club Proxying p.2/24 Definition proxy \Prox"y\, n.; pl. Proxies. The agency for another who acts through the agent; authority

More information

CS 43: Computer Networks. HTTP September 10, 2018

CS 43: Computer Networks. HTTP September 10, 2018 CS 43: Computer Networks HTTP September 10, 2018 Reading Quiz Lecture 4 - Slide 2 Five-layer protocol stack HTTP Request message Headers protocol delineators Last class Lecture 4 - Slide 3 HTTP GET vs.

More information

WEB TECHNOLOGIES CHAPTER 1

WEB TECHNOLOGIES CHAPTER 1 WEB TECHNOLOGIES CHAPTER 1 WEB ESSENTIALS: CLIENTS, SERVERS, AND COMMUNICATION Modified by Ahmed Sallam Based on original slides by Jeffrey C. Jackson THE INTERNET Technical origin: ARPANET (late 1960

More information

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages

Exceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages References Exceptions "Handling Errors with Exceptions", Java tutorial http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html CSE 413, Autumn 2005 Programming Languages http://www.cs.washington.edu/education/courses/413/05au/

More information

Recitation 13: Proxylab Network and Web

Recitation 13: Proxylab Network and Web 15-213 Recitation 13: Proxylab Network and Web 11 April 2016 Ralf Brown and the 15-213 staff 1 Agenda Reminders Complex Web Pages Proxies Threads Appendix: HTTP 2 Reminders Start working on Proxylab now

More information

DESIGN PATTERN - INTERVIEW QUESTIONS

DESIGN PATTERN - INTERVIEW QUESTIONS DESIGN PATTERN - INTERVIEW QUESTIONS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Design Pattern Interview Questions

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

Configuring Caching Services

Configuring Caching Services CHAPTER 8 This chapter describes how to configure conventional caching services (HTTP, FTP [FTP-over-HTTP caching and native FTP caching], HTTPS, and DNS caching) for centrally managed Content Engines.

More information

Getting Some REST with webmachine. Kevin A. Smith

Getting Some REST with webmachine. Kevin A. Smith Getting Some REST with webmachine Kevin A. Smith What is webmachine? Framework Framework Toolkit A toolkit for building RESTful HTTP resources What is REST? Style not a standard Resources == URLs http://localhost:8000/hello_world

More information

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Sp

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Sp Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 4/27/2004 (c) 2001-4, University of

More information

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Au

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE. Representation of Primitive Java Types. CSE143 Au Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Sec. 19.1, Appendix A2 11/2/2003 (c) 2001-3,

More information

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE

Overview CSE 143. Data Representation GREAT IDEAS IN COMPUTER SCIENCE Overview CSE 143 Topics Data representation bits and bytes Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Sec. 19.1, Appendix A2 11/2/2003 (c) 2001-3,

More information

Today. Instance Method Dispatch. Instance Method Dispatch. Instance Method Dispatch 11/29/11. today. last time

Today. Instance Method Dispatch. Instance Method Dispatch. Instance Method Dispatch 11/29/11. today. last time CS2110 Fall 2011 Lecture 25 Java program last time Java compiler Java bytecode (.class files) Compile for platform with JIT Interpret with JVM Under the Hood: The Java Virtual Machine, Part II 1 run native

More information

Overview CSE 143. Input and Output. Streams. Other Possible Kinds of Stream Converters. Stream after Stream... CSE143 Wi

Overview CSE 143. Input and Output. Streams. Other Possible Kinds of Stream Converters. Stream after Stream... CSE143 Wi CSE 143 Overview Topics Streams communicating with the outside world Basic Java files Other stream classes Streams Reading: Ch. 16 2/3/2005 (c) 2001-5, University of Washington 12-1 2/3/2005 (c) 2001-5,

More information

An Example of Protocol: TFTP. EDA095 Web Protocols and Architecture. TFTP: The Packets I. TFTP: Errors

An Example of Protocol: TFTP. EDA095 Web Protocols and Architecture. TFTP: The Packets I. TFTP: Errors An Example of Protocol: TFTP EDA095 Web Protocols and Architecture Pierre Nugues Lund University http://cs.lth.se/home/pierre_nugues/ May 16, 2013 Covers: Chapter 15, pages 493 551, Java Network Programming,

More information

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming

COMP 213. Advanced Object-oriented Programming. Lecture 20. Network Programming COMP 213 Advanced Object-oriented Programming Lecture 20 Network Programming Network Programming A network consists of several computers connected so that data can be sent from one to another. Network

More information

An Example of Protocol: TFTP. EDA095 Web Protocols and Architecture. TFTP: The Packets I. TFTP: Errors

An Example of Protocol: TFTP. EDA095 Web Protocols and Architecture. TFTP: The Packets I. TFTP: Errors An Example of Protocol: TFTP EDA095 Web Protocols and Architecture Pierre Nugues Lund University http://cs.lth.se/home/pierre_nugues/ May 12, 2010 Covers: Chapter 15, pages 493 551, Java Network Programming,

More information

Interprocess Communication

Interprocess Communication Interprocess Communication Nicola Dragoni Embedded Systems Engineering DTU Informatics 4.2 Characteristics, Sockets, Client-Server Communication: UDP vs TCP 4.4 Group (Multicast) Communication The Characteristics

More information

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

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

More information

Create and Apply Clientless SSL VPN Policies for Accessing. Connection Profile Attributes for Clientless SSL VPN

Create and Apply Clientless SSL VPN Policies for Accessing. Connection Profile Attributes for Clientless SSL VPN Create and Apply Clientless SSL VPN Policies for Accessing Resources, page 1 Connection Profile Attributes for Clientless SSL VPN, page 1 Group Policy and User Attributes for Clientless SSL VPN, page 3

More information

Networking Basics. network communication.

Networking Basics. network communication. JAVA NETWORKING API Networking Basics When you write Java programs that communicate over the network, you are programming at the application layer. Typically, you don't need to concern yourself with the

More information

6.824 Lab 2: A concurrent web proxy

6.824 Lab 2: A concurrent web proxy Page 1 of 6 6.824 - Fall 2002 6.824 Lab 2: A concurrent web proxy Introduction In this lab assignment you will write an event-driven web proxy to learn how to build servers that support concurrency. For

More information

20.6. urllib2 extensible library for opening URLs

20.6. urllib2 extensible library for opening URLs 1 of 16 01/25/2012 11:20 AM 20.6. urllib2 extensible library for opening URLs Note: The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3

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

Application Level Protocols

Application Level Protocols Application Level Protocols 2 Application Level Protocols Applications handle different kinds of content e.g.. e-mail, web pages, voice Different types of content require different kinds of protocols Application

More information

Hypertext Transport Protocol

Hypertext Transport Protocol Hypertext Transport Protocol CSE 333 Summer 2018 Instructor: Hal Perkins Teaching Assistants: Renshu Gu William Kim Soumya Vasisht Administriia Section tomorrow: pthread tutorial/demo Followup exercise

More information

Abstract Classes, Exceptions

Abstract Classes, Exceptions CISC 370: Inheritance, Abstract Classes, Exceptions June 15, 1 2006 1 Review Quizzes Grades on CPM Conventions Class names are capitalized Object names/variables are lower case String.doStuff dostuff();

More information