Java SERVLET 01

What is a servlet ?

  • Servlet is a technology that is used to create web application.
  • Servlet is an API that provides many interfaces and classes including documentations.
  • Java Servlets are programs that run on a web server and used for developing web applications.
    we can understand about servlet by this example. Let’s consider where we need to log on to a web site to access our e-mail account. We have to submit username and password for authentication. Then web site accept the login information and validates it using server side programs. (like servlets)
Capture
client -> server -> response -> client

 

  1. request
  2. response is generated at runtime.
  3. response is sent to the client.

JSP

OK let’s see what is JSP(java servlet pages)

Java Server Pages (JSP) is a technology for developing web pages that support dynamic content which helps developers insert java code in HTML pages by making use of special JSP tags, most of which start with <% and end with %>

Simply we can understand it by this…..


Capture1.JPG

This is a simple jsp program. We save this as  filename.jsp
JSP is used for creating dynamic webpages. Dynamic webpages can have two types of contents – static & dynamic content. The static contents can have text-based formats such as HTML,  XML etc. and the dynamic contents are generated by JSP elements.

I know u have no clear idea about jsp yet 🙂 ok first let’s look about
jsp processing.

  • your browser sends an HTTP request to the web server.
  • The web server recognizes that the HTTP request is for a JSP page and forwards it to a JSP engine.
  • The JSP engine loads the JSP page from disk and converts it into a servlet content.(all template text is converted to println( ) statements and all JSP elements are converted to Java code that implements the corresponding dynamic behavior of the page.)
  • The JSP engine compiles the servlet into an executable class and forwards the original request to a servlet engine.
  • The servlet engine loads the Servlet class and executes it. During execution, the servlet produces an output in HTML format, which the servlet engine passes to the web server inside an HTTP response.
  • The web server forwards the HTTP response to your browser in terms of static HTML content.
  • Finally web browser handles the dynamically generated HTML page inside the HTTP response exactly as if it were a static page.

 

OK now we know some facts about jsp servlet. (actually nothing 😀 ) next part we will know something more………………..
LEARN SOMETHING