Java Reference
In-Depth Information
Figure 8-12.
Servlets
Servlets are Java classes that reside on a server and can be accessed with a browser. Servlets can perform any Java
command but, more importantly, servlets can send HTML back to a browser. To explain how the servlet does this we
need to go into a little more detail about how the browser and server work.
Up until now, we have only used the browser to view a Web page. However, instead of specifying a Web page
URL (i.e., http://My.Website.com/Howdy.html ) a servlet URL can be specified. The servlet URL consists of the
RAD server's (i.e., the host's) address, which resides on the PC you are working on and is identified in the URL as
http://localhost:9080 . Then, after the host address, specify the project name (/ TutorialsWeb ) and the name of
the servlet (i.e., /MyFirstServlet ) separated by forward slashes. The ability to access servlets also highlights why Web
addresses are called Uniform Resource Locators, not Uniform Web Page Locators: URLs can identify more than just
HTML files.
Rather than specifying a servlet's URL, servlets can also be invoked from a form . A form is an area of a Web page
that contains a submit button and components where information can be entered. (If you have ever bought anything
on the Internet, you have filled out a form that has at least “name,” “address,” and “credit card number” text fields.)
When you specify a Web page (e.g., you enter a URL and press Enter or you click on a hyperlink), the browser
sends a request to the server for that Web page. This type of request is called a Get request . If you are using a form and
click the submit button, the same thing happens—a request is created and sent to the server. However, in this case
 
Search WWH ::




Custom Search