Introduction to Servlet & JSP

Introduction to Servlet & JSP
------------------------------------

As we did in our previous summary, we will begin by learning some new vocabulary about Servlet and JSP:

   -Servlet: Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model
   -JSP: Java Server Page helps developers to do dynamic web pages based on HTML or XML
   -HTML: HyperText Markup Language
   -CGI: Common Gateway Interface, here we still don’t need to understand much about it, we just take it as it is.
   -GUI: Graphical User Interface
   -URL: Uniform Resource Locator
   -MIME TYPE: Is the content-type response header’s value
   -404 Not Found:  Common error when the server can’t find what it thinks you asked for.


   The problem which makes us learn and use Servlet and JSP is that we find that if we need more people to use our applications it have to be accessed thought the internet, and as we know the web browsers use the HTML language to read and send message by HTTP protocol (Protocol used under TCP/IP, for more information….”WIKIPEDIA”). The next problem was how to make those HTML pages be dynamic. The solution to all of that was Servlet, which is a Java programming language class which is use to add servers capabilities through request-response to get and give changeable data, JSP which could write java code into a HTML file.

    But we still ask ourselves, what is the process? How all these process are going on?
The process is that our browser will send a request (by the URL) to the server asking it to give back a file, an html, a PDF, etc… The server will answer through the HTTP the response on the form of an HTML file. The request stream will be containing the HTTP method to be performed (doGet(), doPost(), or others), the page to be accessed (URL) and the parameters. The Response stream will be containing a status code which will determine if the request was successful or not, the content-type (if it is a PDF, an HTML or others) and at the end the content.

What is the difference between doGet() and doPost()?
doGet() will only go to find something back to the server while doPost() will do so and give also some data to the server. This is the case of login that our username and password must be given to the server to guaranty if it is the right user.

At the end let's talk about the URL and it’s part.
Here is an example of URL: http://localhost:8080/ServletTest/Sample/index.html

   -HTTP://  is the Protocol which tell the server which communication protocol will be used
   -“localhost” is the Server, the unique name of the physical server which can be replaced by an IP address.
   -“/ServletTest/Sample” is the path of to the location on the server of the resource being requested.
   -“index.html” is the resource name, the name of the content being requested. It can be a PDF, a picture, a music, a movie, etc…

你可能感兴趣的:(java,jsp,Web,servlet)