没有合适的资源?快使用搜索试试~ 我知道了~
高校学生公寓管理系统_外文翻译(范文).doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 97 浏览量
2022-06-23
07:26:41
上传
评论
收藏 84KB DOC 举报
温馨提示
试读
21页
高校学生公寓管理系统_外文翻译(范文)
资源推荐
资源详情
资源评论
外文文献资料
HTTP and Servlet Basics
Let's start off this chapter by defining the term web application. We've all seen
regular client-side applications, but what exactly is a web application? Loosely, it
can be defined as an application running on a server a user accesses through a thin,
general-purpose client. Today, the most common client is a web browser on a PC
or workstation, but other kinds of clients are rapidly joining the party, such as
wireless PDAs, cell phones, and other specialized devices.
The lofty goal here is to access all the information and services you need from
any type of device that happens to be in front of you. This means that the same
simple client program must be able to talk to many different server applications,
and the applications must be able to work with many different types of clients. To
satisfy this need, the protocol of how a client and a server talk to each other must
be defined in detail. That's exactly what the HyperText Transport Protocol (HTTP)
is for.
The communication model defined by HTTP forms the foundation for all web
application design. A basic understanding of HTTP is key to developing
applications that fit within the constraints of the protocol, no matter which server-
side technology you use. In this chapter, we look at the most important details of
HTTP you need to be aware of as a web application developer.
One other item: this book is about using JSP as the server-side technology.
JSP is based on the Java servlet technology. Both technologies share a lot of
terminology and concepts, so knowing a bit about servlets will help you even when
you develop pure JSP applications. To really understand and use the full power of
JSP, you need to know a fair bit about servlets. Hence, we look at servlet
fundamentals in the last section of this chapter.
2.1 The HTTP Request/Response Model
HTTP and all extended protocols based on HTTP are based on a very simple
communications model. Here's how it works: a client, typically a web browser,
sends a request for a resource to a server, and the server sends back a response
corresponding to the resource (or a response with an error message if it can't
process the request for some reason). A resource can be a number of things, such as
a simple HTML file returned verbatim to the browser or a program that generates
the response dynamically.
This simple model implies three important facts you need to be aware of:
HTTP is a stateless protocol. This means that the server doesn't keep any
information about the client after it sends its response, and therefore it can't
recognize that multiple requests from the same client may be related.
Web applications can't easily provide the kind of immediate feedback
typically found in standalone GUI applications such as word processors or
traditional client/server applications. Every interaction between the client and the
server requires a request/response exchange. Performing a request/response
exchange when a user selects an item in a list box or fills out a form element is
usually too taxing on the bandwidth available to most Internet users.
There's nothing in the protocol that tells the server how a request is made;
consequently, the server can't distinguish between various methods of triggering
the request on the client. For example, HTTP doesn't allow a web server to
differentiate between an explicit request caused by clicking a link or submitting a
form and an implicit request caused by resizing the browser window or using the
browser's Back button. In addition, HTTP doesn't contain any means for the server
to invoke client specific functions, such as going back in the browser history list or
sending the response to a certain frame. Also, the server can't detect when the user
closes the browser.
Over the years, people have developed various tricks to overcome the first
problem; HTTP's stateless nature. The other two problems—no immediate
feedback and no details about how the request is made—are harder to deal with,
but some amount of interactivity can be achieved by generating a response that
includes client-side code (code executed by the browser), such as JavaScript or a
Java applet.
2.1.1 Requests in Detail
Let's take a closer look at requests. A user sends a request to the server by
clicking a link on a web page, submitting a form, or typing in a web page address
in the browser's address field. To send a request, the browser needs to know which
server to talk to and which resource to ask for. This information is specified by an
HTTP Uniform Resource Locator (URL):
http://www.gefionsoftware.com/index.html
The first part of the URL shown specifies that the request is made using the
HTTP protocol. This is followed by the name of the server, in this case
www.gefionsoftware.com. The web server waits for requests to come in on a
specific TCP/IP port. Port number 80 is the standard port for HTTP requests. If the
web server uses another port, the URL must specify the port number in addition to
the server name. For example:
http://www.gefionsoftware.com:8080/index.html
This request is sent to a server that uses port 8080 instead of 80. The last part
of the URL, /index.html, identifies the resource that the client is requesting.
A URL is actually a specialization of a Uniform Resource Identifier (URI,
defined in the RFC-2396 specification). A URL identifies a resource partly by its
location, for instance the server that contains the resource. Another type of URI is a
Uniform Resource Name (URN), which is a globally unique identifier that is valid
no matter where the resource is located. HTTP deals only with the URL variety.
The terms URI and URL are often used interchangeable, and unfortunately, they
have slightly different definitions in different specifications. I'm trying to use the
terms as defined by the HTTP/1.1 specification (RFC-2616), which is pretty close
to how they are also used in the servlet and JSP specifications. Hence, I use the
term URL only when the URI must start with http (or https, for HTTP over an
encrypted connection) followed by a server name and possibly a port number, as in
the previous examples. I use URI as a generic term for any string that identifies a
resource, where the location can be deduced from the context and isn't necessarily
part of the URI. For example, when the request has been delivered to the server,
the location is a given, and only the resource identifier is important.
The browser uses the URL information to create the request message it sends
to the specified server using the specified protocol. An HTTP request message
consists of three things: a request line, request headers, and possibly a request
body.
The request line starts with the request method name, followed by a resource
identifier and the protocol version used by the browser:
GET /index.html HTTP/1.1
The most commonly used request method is named GET. As the name
implies, a GET request is used to retrieve a resource from the server. It's the default
request method, so if you type a URL in the browser's address field, or click on a
link, the request is sent as a GET request to the server.
The request headers provide additional information the server may use to
process the request. The message body is included only in some types of requests,
like the POST request discussed later.
Here's an example of a valid HTTP request message:
GET /index.html HTTP/1.1
Host: www.gefionsoftware.com
User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; en-US; rv: 1.0.2)
Accept: image/gif, image/jpeg, image/pjpeg, image/png, */*
Accept-Language : en
Accept-Charset : iso-8859-1,*,utf-8
The request line specifies the GET method and asks for the resource named
/index.html to be returned using the HTTP/1.1 protocol version. The various
headers provide additional information.
The Host header tells the server the hostname used in the URL. A server may
have multiple names, so this information is used to distinguish between multiple
virtual web servers sharing the same web server process.
The User-Agent header contains information about the type of browser
making the request. The server can use this to send different types of responses to
different types of browsers. For instance, if the server knows whether Internet
Explorer or Netscape Navigator is used, it can send a response that takes advantage
of each browser's unique features. It can also tell if a client other than an HTML
browser is used, such as a Wireless Markup Language (WML) browser on a cell
phone or a PDA device, and generate an appropriate response.
The Accept headers provide information about the languages and file formats
the browser accepts. These headers can be used to adjust the response to the
capabilities of the browser and the user's preferences, such as use a supported
image format and the preferred language. These are just a few of the headers that
can be included in a request message.
The resource identifier (URI) doesn't necessarily correspond to a static file on
the server. It can identify an executable program, a record in a database, or pretty
much anything the web server knows about. That's why the generic term resource
is used. In fact, there's no way to tell if the /index.html URI corresponds to a file or
something else; it's just a name that means something to the server. The web server
is configured to map these unique names to the real resources.
2.1.2 Responses in Detail
When the web server receives the request, it looks at the URI and decides,
based on configuration information, how to handle it. It may handle it internally by
simply reading an HTML file from the filesystem, or it can forward the request to
some component that is responsible for the resource corresponding to the URI.
This can be a program that uses database information, for instance, to dynamically
generate an appropriate response. To the browser it makes no difference how the
request is handled; all it cares about is getting a response.
The response message looks similar to the request message. It consists of
three things: a status line, response headers, and an optional response body. Here's
an example:
HTTP/1.1 200 OK
Last-Modified: Mon, 20 Dec 2002 23:26:42 GMT
Date: Tue, 11 Jan 2003 20:52:40 GMT
Status: 200
Content-Type: text/html
Servlet-Engine: Tomcat Web Server/5.0
Content-Length: 59
<html>
<body>
<h1>Hello World!</h1>
剩余20页未读,继续阅读
资源评论
oligaga
- 粉丝: 52
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenrecording_20240509_230927_20240509_231814.mp3
- 基于Dart的复健科东方国际咖啡馆管理系统设计源码
- Python 常用标准库模块 1
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例典型案例:万达消防系统图
- 一篇精雕细琢的 Python 进阶总结
- man,what can I say;
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例第四篇:电缆分接箱部分
- 一篇精雕细琢的 Python 入门总结
- 基于 vxe-table 表格的适配插件,用于兼容 ant-design-vue 组件库
- 弱电系统方案设计安防监控技术资料门禁网络工程图纸报价资料图纸案例第三部分:开关站通用设计模块(24张)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功