servlets-notes-form-hyderabad-training-institute (1).pdf | Java Servlet | Dynamic Web Page

Please download to get full document.

View again

of 47
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report
Category:

Documents

Published:

Views: 16 | Pages: 47

Extension: PDF | Download: 0

Share
Related documents
Description
www.JavaEra.com SERVLETS INTRODUCTION Why there is a need for Server-side programming? In applets, processing takes place at the client side. So, the burden on client side has increased when the process is more complex. As applets are not permitted to write to the client machine’s local disk, they had to suffer some efficiency problems when it comes to complex situations. Moreover, the need for makin
Transcript
  󰁷󰁷󰁷󰀮󰁊󰁡󰁶󰁡󰁅󰁲󰁡󰀮󰁣󰁯󰁭 74 SERVLETS INTRODUCTION Why there is a need for Server-side programming? In applets, processing takes place at the client side. So, the burden on client side has increased when the process is more complex. As applets are not permitted to write to the client machine’s local disk, they had to suffer some efficiency problems when it comes to complex situations. Moreover, the need for making the client a ‘thin client’ has become more important to give faster access to the client. Applets are quite slow and all the browsers should support the applets. Keeping this in view a server-side program is developed, it is known as servlets, where there is no complexity on the client side. World Wide Web The World Wide Web is a huge collection of interconnected hypertext documents on the Internet. A hypertext document that contains hot links to other documents. There are many thousands of hypertext authors on the Internet, each of them free to connect their documents to anyone else. The Web is based on two standards: HTTP protocol and the HTML language. HTTP stands for HyperText Transfer Protocol and it describes the way that hypertext documents are fetched over the internet. HTML is the abbreviation for hypertext markup language, and it describes how the HTML documents are rendered on to the browsers. Resources on the Web are specified with a Uniform Resource Locator (URL). As it is conceived that the WWW is a pure two-tier client-server application. The user interface is “dumb”, just a presentation written in HTML. For a simple document, hyperlinking this is sufficient. The server is also rather dumb. Its only function is to server out HTML pages. It contains no logic other than this. Dynamic content Very early in the evolution of the WWW developers needed a mechanism to add some ‘smarts’ to the server side. While a web page merely displays static content and lets the user navigate through that content, a web application provides a more interactive experience. A web application can be as simple as a keyword search on a document archive or as complex as an electronic storefront. Web applications are being deployed on the Internet and on corporate Intranets and Extranets, where they have the potential to increase productivity and change the way that companies, large and small, do business. There are so many ways to create web applications some of them are discussed here. Common Gateway Interface The Common Gateway Interface normally refereed to, as CGI was one of the first practical techniques for creating dynamic web content.  󰁷󰁷󰁷󰀮󰁊󰁡󰁶󰁡󰁅󰁲󰁡󰀮󰁣󰁯󰁭 75 You can use URLs within an HTTP message to locate a server program anywhere on the Internet. On the receiving end, the typical web server only knows how to handle HTML documents. When it receives a request for a program, it simply turns around and invokes the resource named in the URL, and tells it to take care of the request. The server passes the method request and its parameters to the back-end program using a protocol called the CGI. You can write your CGI programs in any language that can read standard input and write to standard output including Java. The application executes and returns the results in HTML/HTTP format to the server. The server turns around and returns the results to the client. Active Server Pages Active Server Pages (popularly known as ASPs) is a technique developed for generating dynamic web content. With ASP, an HTML page on the web server can contain snippets of embedded code (usually VBScript or Jscript – although it’spossible to use nearly any language). This code is read and executed by the web server before it sends the page to the client. ASP is optimized for generating small portions of dynamic content. Microsoft’s IIS (Internet Information Server) supports ASPs. 1 WHAT 1.1 Definition Servlet is a web component, managed by a container, that generates dynamic content. “Servlets are small, platform independent Java classes compiled to an architecture neutral bytecode that can be loaded dynamically into and run by a web server.” “Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers.” “Servlet interacts with web clients through a request-response model (which is based on the behavior of HTTP) implemented by the servlet container.” 1.2 Servlet Container Here, we must know what is a Servlet Container. A Servlet container, in conjunction with web server - - provides network services over which request and responses are set - decodes MIME based requests, and - formats MIME based responses.  󰁷󰁷󰁷󰀮󰁊󰁡󰁶󰁡󰁅󰁲󰁡󰀮󰁣󰁯󰁭 76 A Servlet Container can be built into a host web server, or it can be installed as an add-on component to a web server. A servlet container must support HTTP as protocol for requests and responses. The minimum required version of HTTP is 1.0. 1.3 HTTP basics Before going into the details of Servlets you must have a basic understanding of how the protocol behind the Web, HTTP works. HTTP is a simple, stateless protocol. A client, such as a web browser, makes a request, the web server responds, and the transaction is done. When the client sends a request, the first thing it specifies is an HTTP command, called a method, that tells the server the type of action it wants performed. This first line of the request also specifies the address of a document (a URL) and the version of the HTTP protocol it is using. For example: GET /intro.html HTTP/1.0 This request uses the GET method to ask for the document named intro.html, using HTTP version 1.0. After sending the request, the client can send optional header information to tell the server extra information about the request, such as what software the client is running and what content types it understands. This information doesn’t directly pertain to what was requested, but it could be used by the server in generating its response. Here are some sample requests headers: User-Agent: Mozilla/4.0 (compatible; MSIE 4.0; Windows 95) Accept: image/gif, image/jpeg, text/*, */* After the headers, the client sends a blank line, to indicate the end of the header section. The client can also send data, if appropriate for the method being used, as it is with the POST method that we’ll discuss shortly. If the request doesn’t send any data it ends with an empty line. After the client sends the request, the server processes it and sends back a response. The first line of the response is a status line that specifies the version of HTTP protocol the server is using, a status code, and a description of the status code. For example, HTTP/1.0 200 OK This status line includes a status code of 200, which indicates that the request was successful, hence, the description “OK”. Another common status code is 404, with the description “not found” – as you can guess, this means that the requested document was not found. After the status line, the server sends response headers that tell the client things like what software the server is running and the content type of the server’s response. For example: Date: Sunday, 14-November-99 03:24:10 GMT Server: JavaWebServer/1.1 MIME-version: 1.0 Content-type: text/html Content-length: 2048 Last-modified: Friday, 12-November-99 08:10:54 GMT The Server header provides information about the server software, while the Content-type header specifies the MIME type of the data included with the response. The server sends a blank line after the headers, to conclude the header section. If the request was successful, the requested data is then sent as a part of the response. Otherwise, the response may contain human readable data that explains why the server couldn’t fulfill the request.
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks