UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory UML Weekend Crash Course™ - To Parent Directory

crnarupa.singidunum.ac.rs
from crnarupa.singidunum.ac.rs More from this publisher
01.01.2015 Views

Session 27—Introduction to Web Development with Java 279 fixed text, images, and hyperlinks to other pages. In this case, you would write an HTML page with this content and place it on your Web server. A shell of the HTML page is shown in Listing 27-1. (HTML is a markup language that is composed of plain text accompanied by markup tags to specify how to format the text. HTML can be stored in a plain text file and does not need to be compiled or processed in any way before it is placed on the Web server.) Listing 27-1 HTML sample Next Step Education Next Step Education (...more content...) HTML is the most common form of Web content and is the form I focus on in this session. However, this session’s discussion of generating and sending Note HTML can also be applied to other forms of Web content, such as XML for data interchange. Usually, HTML files are stored on a Web server and loaded over a network such as the Internet. This architecture is shown in the UML Deployment diagram in Figure 27-1. When the user types a URL into a Web browser, the browser needs to communicate with a Web server to get that document, in this case “index.html.” The HyperText Transfer Protocol (HTTP) defines the communication protocol for that communication between the Web browser and the Web server. Client Web Browser Web Server Web Server index.html Figure 27-1 UML Deployment diagram, HTML on a Web server The full sequence of events for retrieving a Web document is shown in the UML Sequence diagram in Figure 27-2. When the user enters a URL, the Web browser creates an HTTP request, which is a packet of information including the name of the Web server, the name of the document, and other information about the request being made. The Web browser then sends that HTTP request over the network to the Web server that was specified in the URL. The Web Server then looks up the Web page “index.html” and returns it as part of the response.

280 Sunday Afternoon :User :Web Browser :Web Server type URL create HTTP request send HTTP request create HTTP response copy contents of requested HTML file into HTTP response send HTTP response interpret and display HTML Figure 27-2 UML Sequence diagram, HTTP protocol For example, if the URL entered is www.nextstepeducation.com/index.html, the Web request will be sent to the Web server on the machine with a domain name of www. nextstepeducation.com. When the Web server receives the request, it will create an HTTP response, which is a packet of information that includes the requested document or error message and other metadata about the response. The Web server will look for the file that was specified in the URL. In the example in Figure 27-2, the Web server will load the index.html file and place the contents of that file into the HTTP response. The Web server will then send the HTTP response back across the network to the Web browser that made the request. The Web browser will take the HTML out of the HTTP response, interpret it, and display the content with the specified formatting. Tip Some people may question the choice of “objects” in the Sequence diagram in Figure 27-2. In truth, a Web browser is simply a larger, more complex object than a customer or an order. This approach is common practice when modeling interaction between systems (that is, when modeling the systems as objects). Dynamic Web Content The previous section showed how HTTP is used to send static HTML content to Web browsers. Most Web applications require dynamically generated content. For example, when you go to a weather forecast Web site, you don’t want it to give you the contents of an HTML file that was saved a month ago; you want it to generate an up-to-date weather forecast for you on the spot and return it to you. Furthermore, you want to be able to access weather information for a certain city. Thus, there must be some programming logic that can take your user input and adapt the result to your request. So a weather Web site would

280<br />

Sunday Afternoon<br />

<br />

:User<br />

:Web Browser<br />

:Web Server<br />

type URL<br />

create HTTP request<br />

send HTTP request<br />

create HTTP response<br />

copy contents of requested<br />

HTML file into HTTP response<br />

send HTTP response<br />

interpret and display HTML<br />

Figure 27-2 <strong>UML</strong> Sequence diagram, HTTP protocol<br />

For example, if the URL entered is www.nextstepeducation.com/index.html, the<br />

Web request will be sent to the Web server on the machine with a domain name of www.<br />

nextstepeducation.com. When the Web server receives the request, it will create an HTTP<br />

response, which is a packet of information that includes the requested document or error<br />

message and other metadata about the response. The Web server will look for the file that<br />

was specified in the URL. In the example in Figure 27-2, the Web server will load the<br />

index.html file and place the contents of that file into the HTTP response. The Web server<br />

will then send the HTTP response back across the network to the Web browser that made<br />

the request. The Web browser will take the HTML out of the HTTP response, interpret it, and<br />

display the content with the specified formatting.<br />

Tip<br />

Some people may question the choice of “objects” in the Sequence diagram<br />

in Figure 27-2. In truth, a Web browser is simply a larger, more complex<br />

object than a customer or an order. This approach is common practice when<br />

modeling interaction between systems (that is, when modeling the systems<br />

as objects).<br />

Dynamic Web Content<br />

The previous section showed how HTTP is used to send static HTML content to Web<br />

browsers. Most Web applications require dynamically generated content. For example, when<br />

you go to a weather forecast Web site, you don’t want it to give you the contents of an<br />

HTML file that was saved a month ago; you want it to generate an up-to-date weather forecast<br />

for you on the spot and return it to you. Furthermore, you want to be able to access<br />

weather information for a certain city. Thus, there must be some programming logic that<br />

can take your user input and adapt the result to your request. So a weather Web site would

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!