Summary

 < Free Open Study > 



We have examined the Hypertext Transfer Protocol in some detail, including the protocol layers HTTP sits upon to function. We examined how state and connections are managed, and looked at security and authentication in the protocol. The HTTP 1.0 and now the 1.1 standard is evolving with varying levels of implementation and support.

This chapter explained how to use HTTP requests and responses with servlets, namely with javax.servlet.http.HttpServlet. We focused upon the HTTP 1.0-based methods such as doGet(), doPost() and doHead(), and followed this by discussing the less frequently-used methods relating to HTTP 1.1 too: doDelete(), doPut(), doOptions() and doTrace().

The javax.servlet.http.HttpServletRequest interface provides access to the clients' request information, including headers, attributes, paths, authentication, sessions, cookies, and internationalization. Similarly the javax.servlet.http.HttpServletResponse interface allows us access to the server's response, including methods assessing headers, redirection, status codes and errors, cookies, session management, internationalization and buffering. Finally the HttpServletRequestWrapper and the HttpServletResponseWrapper allow developers to extend the functionality of these request and response interfaces.

We concluded the chapter by developing an HTTP-based client-servlet application. This demonstrated some of the techniques involved in HTTP communications to and from a servlet. In this case we looked at a servlet processing a Java application's requests, received over HTTP. We considered the extensible design of the server classes, including the servlet, the handler classes, and the handler factory class we constructed.

In the following chapter we will discuss the deployment of web applications.

A

accept() method, FileExchangeFilter class

  • HTTP based client-servlet application, 42

addDateHeader() method, HttpServletResponse interface

  • HTTP requests and responses, 15

addHeader() method, HttpServletResponse interface

  • HTTP requests and responses, 15

addIntHeader() method, HttpServletResponse interface

  • HTTP requests and responses, 16

appendMessage() method, FileExchangeView class

  • HTTP based client-servlet application, 34

application layer protocols, 1

authentication

  • HTTP authentication, 5

  • HttpServletRequest interface, 14

B

Base 64 encoding

  • Basic Access Authentication, HTTP, 5

BaseRequest class

  • HTTP based client-servlet application, 30, 43

Basic Access Authentication, HTTP

  • how it works, 5

C

classes

  • BaseRequest class, 43

  • DeleteHandler class, 56

  • DownloadHandler class, 54

  • FileExchangeServlet class, 47

  • FileFilter abstract class, 42

  • FileList class, 30, 44

  • FileName class, 44

  • FileValidator class, 45

  • HTMLTable utility class, 18

  • HTTP based client-servlet application, 29

  • HttpServlet class, javax.servlet.http, 7

  • RefreshHandler class, 54

  • RequestHandler class, 46, 51

  • RequestHandlerFactory class, 49

cleanFileList() method, FileValidator class

  • HTTP based client-servlet application, 45

client GUI

  • HTTP based client-servlet application, 27

client implementation

  • HTTP based client-servlet application, 30

containsHeader() method, HttpServletResponse interface

  • HTTP requests and responses, 16

cookies

  • implementing HTTP servlets, 19

custom clients

  • servlets, 25

D

DELETE method, HTTP, 3

  • HTTP based client-servlet application, 49

delete() method, DeleteHandler class

  • HTTP based client-servlet application, 56

DeleteHandler class

  • delete() method, 56

  • HTTP based client-servlet application, 29, 56

deleteRequest() method, FileExchangeModel class

  • HTTP based client-servlet application, 39

destroy() method, HttpServlet class

  • HttpServlet overrides, 8

Digest Access Authentication, 6

doGet() method

  • implementing HTTP servlets, 19, 21

doGet() method, FileExchangeServlet class

  • HTTP based client-servlet application, 49

doHead() method, HttpServlet class

  • handling HTTP requests, 9

doPost() method

  • implementing HTTP servlets, 21

doPost() method, FileExchangeServlet class

  • HTTP based client-servlet application, 48, 49

doQuestion() method

  • QuizServlet, 23

doTrace method, HttpServlet class

  • handling HTTP requests, 10

DownloadHandler class

  • HTTP based client-servlet application, 29, 54

downloadRequest() method, FileExchangeModel class

  • HTTP based client-servlet application, 36

E

encodeRedirectURL() method,

  • HttpServletResponse interface

  • HTTP requests and responses, 16

Entity headers, HTTP

  • when used, 4

errors, HTTP

  • HttpServletResponse class, 17

F

Factory pattern

  • HTTP based client-servlet application, 46

FileExchangeApplication class

  • HTTP based client-servlet application, 29, 30

  • main() method, 31

FileExchangeFilter class

  • accept() method, 42

  • getDescription() method, 42

  • getExtension() method, 42

  • HTTP based client-servlet application, 29, 41

FileExchangeModel class

  • deleteRequest() method, 39

  • downloadRequest() method, 36

  • flush() method, 41

  • getHttpURLConnection() method, 35, 37

  • HTTP based client-servlet application, 29, 34

  • readResponse() method, 41

  • refreshRequest() method, 38, 39

  • sendRequest() method, 35, 37, 40

  • setDoOutput() method, 40

  • setUseCaches() method, 40

  • uploadRequest() method, 35

FileExchangeModel object

  • HTTP based client-servlet application, 32

FileExchangeServlet class

  • doGet() method, 49

  • doPost() method, 48, 49

  • getRequestType() method, 48

  • HTTP based client-servlet application, 29, 46, 47

  • init() method, 48

  • readSerializedObject() method, 49

  • respond() method, 49

FileExchangeView class

  • appendMessage() method, 34

  • HTTP based client-servlet application, 29, 31, 34

  • refreshFileList() method, 34

FileExchangeView object

  • HTTP based client-servlet application, 30

FileFilter abstract class

  • HTTP based client-servlet application, 42

FileList class

  • HTTP based client-servlet application, 30, 44

FileName class

  • HTTP based client-servlet application, 30, 44

FileValidator class

  • cleanFileList() method, 45

  • HTTP based client-servlet application, 30, 45

  • isFileNameValid() method, 45

firewall subdirectories

  • HTTP based client-servlet application, 57

firewall.client package

  • HTTP based client-servlet application, 28

firewall.common package

  • HTTP based client-servlet application, 29

firewall.server package

  • HTTP based client-servlet application, 29

flush() method, FileExchangeModel class

  • HTTP based client-servlet application, 41

G

General headers, HTTP

  • when used, 4

GET method, HTTP, 3

  • handling HTTP requests, 9

GET request type

  • HTTP based client-servlet application, 49

  • implementing HTTP servlets, 24

getAuthType() method, HttpServletRequest interface

  • HTTP requests and responses, 14

getContextPath() method, HttpServletRequest interface

  • HTTP requests and responses, 12

getDateHeader() method, HttpServletRequest interface

  • HTTP requests and responses, 11

getDescription() method, FileExchangeFilter class

  • HTTP based client-servlet application, 42

getExtension() method, FileExchangeFilter class

  • HTTP based client-servlet application, 42

getFile() method, RequestHandler class

  • HTTP based client-servlet application, 52

getFileList() method, RequestHandler class

  • HTTP based client-servlet application, 52

getHandler() method, RequestHandlerFactory class

  • HTTP based client-servlet application, 50

getHeader() method, HttpServletRequest interface

  • HTTP requests and responses, 11

  • implementing HTTP servlets, 20

getHeaderNames() method, HttpServletRequest interface

  • HTTP requests and responses, 10

getHeaders() method, HttpServletRequest interface

  • HTTP requests and responses, 11

getHttpRequestTable() method

  • implementing HTTP servlets, 19

getHttpResponseTable() method

  • implementing HTTP servlets, 19

getHttpURLConnection() method,

  • FileExchangeModel class

  • HTTP based client-servlet application, 35, 37

getInstance() method, HTTP

  • HTTP based client-servlet application, 46

getIntHeader() method, HttpServletRequest interface

  • HTTP requests and responses, 11

getLastModified method, HttpServlet class

  • handling HTTP requests, 10

getMethod() method, HttpServletRequest interface

  • HTTP requests and responses, 10

getPathInfo() method, HttpServletRequest interface

  • HTTP requests and responses, 12

getPathTranslated() method, HttpServletRequest interface

  • HTTP requests and responses, 13

getQueryString() method, HttpServletRequest interface

  • HTTP requests and responses, 12

getRemoteUser() method, HttpServletRequest interface

  • HTTP requests and responses, 14

getRequestHandlerFactory() method,

  • RequestHandlerFactory class

  • HTTP based client-servlet application, 50

getRequestType() method, FileExchangeServlet class

  • HTTP based client-servlet application, 48

getRequestURI() method, HttpServletRequest interface

  • HTTP requests and responses, 13

getRequestURL() method, HttpServletRequest interface

  • HTTP requests and responses, 13

getServletPath() method, HttpServletRequest interface

  • HTTP requests and responses, 12

getUserPrincipal() method, HttpServletRequest interface

  • HTTP requests and responses, 14

H

HEAD method, HTTP, 3

headers

  • !see also p.HTTP headers.

  • HTTP headers, 4

    • output, table of example values, 12

  • HttpServletRequest interface, 10

  • HttpServletResponse interface,

    • javax.servlet.http, 15

HTMLTable utility class

  • implementing HTTP servlets, 18

HTTP (Hypertext Transfer Protocol)

  • authentication, 5

  • headers, 4

  • introduction, 2

  • methods, 3

  • request handling, 9

  • requests, 10

  • responses, 10

  • servlets and, 6

  • status codes, 4

HTTP based client-servlet application, 26-58

  • classes

    • FileExchangeApplication class, 30

    • FileExchangeFilter class, 41

    • FileExchangeModel class, 34

    • FileExchangeView class, 31

  • classes overview, 29

  • client GUI, 27

  • client implementation, 30

  • common classes, implementing, 43

    • BaseRequest class, 43

    • DeleteHandler class, 56

    • DownloadHandler class, 54

    • FileExchangeServlet class, 47

    • FileList class, 44

    • FileValidator class, 45

    • RefreshHandler class, 54

    • RequestHandler class, 51

    • RequestHandlerFactory class, 49

    • UploadHandler class, 55

  • compiling and running, 57

  • FileName class, 44

  • planning, 28

  • web application, implementing, 46

HTTP Basic Access Authentication

  • how it works, 5

HTTP headers

  • categories of header, 4

  • Entity headers information, 4

  • General header information, 4

  • output, table of example values, 12

  • Request headers information, 4

  • Response headers information, 4

HTTP methods

  • DELETE method, 3

  • GET method, 3

  • HEAD method, 3

  • POST method, 3

  • PUT method, 3

HTTP servlets, 1

  • HttpRequestResponseServlet, 17

  • implementing, 17

  • QuizServlet, 21

HttpRequestResponseServlet class

  • example, compiling and running, 20

  • implementing HTTP servlets, 17

HttpServlet class, javax.servlet.http, 7

  • destroy() method, 8

  • doHead() method, 9

  • doTrace method, 10

  • getLastModified method, 10

  • init() method, 8

  • lifecycle methods, 8

  • service methods, 8

  • service() method, 7

HttpServletRequest interface, javax.servlet.http, 10

  • authentication information, 14

  • getAuthType() method, 14

  • getContextPath() method, 12

  • getDateHeader() method, 11

  • getHeader() method, 11

  • getHeaderNames() method, 10

  • getHeaders() method, 11

  • getIntHeader() method, 11

  • getMethod() method, 10

  • getPathInfo() method, 12

  • getPathTranslated() method, 13

  • getQueryString() method, 12

  • getRemoteUser() method, 14

  • getRequestURI() method, 13

  • getRequestURL() method, 13

  • getServletPath() method, 12

  • getUserPrincipal() method, 14

  • header information, 10

  • introduction, 4

  • path information, 12

HttpServletResponse class, javax.servlet.http

  • errors, 17

  • methods, 17

  • status codes, 16

HttpServletResponse interface, javax.servlet.http, 14

  • addDateHeader() method, 15

  • addHeader() method, 15

  • addIntHeader() method, 16

  • containsHeader() method, 16

  • encodeRedirectURL() method, 16

  • headers, 15

  • isCommitted() method, 16

  • MIME types, 15

  • redirecting requests, 16

  • sendError() method, 17

  • sendRedirect() method, 16

  • setContentLength() method, 15

  • setContentType() method, 15

  • setDateHeader() method, 15

  • setHeader() method, 15

  • setIntHeader() method, 16

  • setStatus() method, 17

I

init() method, FileExchangeServlet class

  • HTTP based client-servlet application, 48

init() method, HttpServlet class

  • HttpServlet overrides, 8

init() method, RequestHandler class

  • HTTP based client-servlet application, 52

InputStreamReader

  • HTTP based client-servlet application, 37

instantiateHandler() method, RequestHandler class

  • HTTP based client-servlet application, 50, 51

interfaces

  • HttpServletRequest interface, 10

isCommitted() method, HttpServletResponse interface

  • HTTP requests and responses, 16

isFileNameValid() method, FileValidator class

  • HTTP based client-servlet application, 45

J

javax.servlet package

  • introduction, 6

javax.servlet.http package

  • diagram of classes and interfaces, 6

  • introduction, 6

JFileChooser, javax.swing

  • HTTP based client-servlet application, 27

JList, javax.swing

  • HTTP based client-servlet application, 27

JTextArea, javax.swing

  • HTTP based client-servlet application, 27

M

main() method, FileExchangeApplication class

  • HTTP based client-servlet application, 31

methods

  • doGet() method, 21

  • doPost() method, 21

  • getHttpRequestTable() method, 19

  • getHttpResponseTable() method, 19

  • getInstance() method, 46

  • HTTP methods, 3

  • HttpServlet class, lifecycle methods, 8

  • HttpServlet class, service methods, 8

  • HttpServletResponse class, 17

  • respond() method, 46

  • setHttpObjects() method, 46

MIME (Multipurpose Internet Mail Extensions) types

  • RFC 2045 and 2046, 15

MIME types

  • HttpServletResponse interface, javax.servlet.http, 15

O

OPTIONS method

  • handling HTTP requests, 9

P

packages

  • !see following packages in index by name.

  • firewall.client package, 28

  • firewall.common package, 29

  • firewall.server package, 29

  • javax.servlet.http package, 6

paths

  • HttpServletRequest interface, 12

patterns

  • Factory pattern, 46

  • Singleton pattern, 46

POST method, HTTP, 3

  • handling HTTP requests, 9

POST request type

  • HTTP based client-servlet application, 49

  • implementing HTTP servlets, 24

protocols

  • application layer protocols, 1

  • different protocols, when used, 2

  • HTTP, 2

PUT method, HTTP, 3

Q

QuizServlet

  • example, compiling and running, 25

  • implementing HTTP servlets, 21

R

readResponse() method, FileExchangeModel class

  • HTTP based client-servlet application, 41

readSerializedObject() method,

  • FileExchangeServlet class

  • HTTP based client-servlet application, 49

refreshFileList() method, FileExchangeView class

  • HTTP based client-servlet application, 34

RefreshHandler class

  • HTTP based client-servlet application, 29, 54

refreshRequest() method, FileExchangeModel class

  • HTTP based client-servlet application, 38, 39

Request headers, HTTP

  • when used, 4

RequestDispatcher object

  • HTTP requests and responses, 16

RequestHandler class

  • getFile() method, 52

  • getFileList() method, 52

  • HTTP based client-servlet application, 29, 46, 51

  • init() method, 52

  • instantiateHandler() method, 50, 51

  • respond() method, 51

  • sendError() method, 53

  • sendFile() method, 53

  • sendSerializedObject() method, 53

  • setHttpObjects() method, 52

  • setStatusCode() method, 53

  • setStringFileBase() method, 53

RequestHandlerFactory class

  • getHandler() method, 50

  • getRequestHandlerFactory() method, 50

  • HTTP based client-servlet application, 29, 46, 50

requests

  • handling HTTP requests, 9

  • HTTP requests, 10

  • redirecting, HttpServletResponse interface, 16

respond() method, FileExchangeServlet class

  • HTTP based client-servlet application, 49

respond() method, RequestHandler class

  • HTTP based client-servlet application, 46, 51

Response headers, HTTP

  • when used, 4

responses

  • HTTP responses, 10

RFC 2045 and 2046, MIME, 15

S

sendError() method, HttpServletResponse interface

  • HTTP requests and responses, 17

sendError() method, RequestHandler class

  • HTTP based client-servlet application, 53

sendFile() method, RequestHandler class

  • HTTP based client-servlet application, 53

sendRedirect() method, HttpServletResponse interface

  • HTTP requests and responses, 16

sendRequest() method, FileExchangeModel class

  • HTTP based client-servlet application, 35, 37, 40

sendSerializedObject() method, RequestHandler class

  • HTTP based client-servlet application, 53

service() method, HttpServlet class

  • HttpServlet overrides, 7

  • service methods, 8

servlets

  • custom clients, 25

  • HTTP and, 6

  • HTTP servlets, 1

  • HttpRequestResponseServlet, 17

  • QuizServlet, 21

setContentLength() method,

  • HttpServletResponse interface

  • HTTP requests and responses, 15

setContentType() method, HttpServletResponse interface

  • HTTP requests and responses, 15

setDateHeader() method, HttpServletResponse interface

  • HTTP requests and responses, 15

setDoOutput() method, FileExchangeModel class

  • HTTP based client-servlet application, 40

setHeader() method, HttpServletResponse interface

  • HTTP requests and responses, 15

setHttpObjects() method

  • HTTP based client-servlet application, 46, 48

setHttpObjects() method, RequestHandler class

  • HTTP based client-servlet application, 52

setIntHeader() method, HttpServletResponse interface

  • HTTP requests and responses, 16

setStatus() method, HttpServletResponse interface

  • HTTP requests and responses, 17

setStatusCode() method, RequestHandler class

  • HTTP based client-servlet application, 53

setStringFileBase() method, RequestHandler class

  • HTTP based client-servlet application, 53

setUseCaches() method, FileExchangeModel class

  • HTTP based client-servlet application, 40

Singleton pattern

  • HTTP based client-servlet application, 46

SSL (Secure Sockets Layer)

  • HTTPS (HTTP SSL), 6

status codes, HTTP, 4

  • HttpServletResponse class, 16

T

TRACE method

  • handling HTTP requests, 9

U

UploadHandler class

  • HTTP based client-servlet application, 29, 55

uploadRequest() method, FileExchangeModel class

  • HTTP based client-servlet application, 35

W

web applications

  • HTTP based client-servlet, implementing, 46



 < Free Open Study > 



Professional Java Servlets 2.3
Professional Java Servlets 2.3
ISBN: 186100561X
EAN: 2147483647
Year: 2006
Pages: 130

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net