SlideShare a Scribd company logo
Prepared using




Unit 2
     HTTP Basics
     Servlet Basics




Presentation by
AshishSingh T Bhatia
Lecturer, CTI
ast.bhatia@gmail.com
Assignment 1

    1. Explain Internet and WWW.
    2. Explain the basic structure of HTML document with
        brief history.
    3. What is JavaScript? Describe its evolution.
    4. Explain different type of datatypes available and use
        in JS.
    5. Write shortnote on DOM.
    6. List and explain different browsers objects.
    7. Explain all form elements.
    8. List and explain JavaScript Event handlers.
    9. Explain in detail Form Object and its use.
    10. Explain inbuilt objects in JavaScript. [ String and Date]
I                                                     Ashish Bhatia
Assignment 1

11. Explain the functions and its use in JavaScript.
12. Explain following with examples
      1. typeof
      2. instanceof
      3. prototype
      4. constructor
      5. caller
      6. toString
      7. valueOf
13. Desribe the object creation in JavaScript with example.


II                                               Ashish Bhatia
HTTP

●   HTTP stands for Hyper Text Transfer Protocol

     HTTP/0.9         HTTP/1.0       HTTP/1.1

      RFC ?           RFC 1945        RFC 2616
●   HTTP is
      ●   Aplication Level Protocol for distributed, collaborative,
          hypermedia information systems.
      ●   Generic stateless protocol which can be used for many
          tasks beyond its use for hypertext .
      ●   Use by WWW since 1990.
      ●   Use reliable TCP / IP connection.
1                                                   Ashish Bhatia
URL , URI , URN

●   URL : Uniform Resource Locator
●   URI : Uniform Resource Identifier
●   URN : Uniform Resource Name




2                                       Ashish Bhatia
URL , URI , URN

●   Web Identifiers
●   Classical View
     ●   [ URI ] Identifier might specify
     ●   location of resource ==> URL
          ●   http://
          ●   identifies a resource via a representation of its
              primary access mechanism
              (e.g., its network "location"),
     ●   Its name independent of location ==> URN
          ●   urn:isbn :n-nn-nnnnnn-n


3                                                       Ashish Bhatia
Move Back to History




4                      Ashish Bhatia
Move Back to History




5                      Ashish Bhatia
Understanding a Bit here

●   Take place of CGI scripts
●   Run inside a JVM [ Making it safe and portable ]
●   Operate solely in domain of server unlike applet they
     do not require support for Java on web Browser.
●   Efficient and Scalable : Threads are used for request.
●   Support for servlet
     ●   Standalone Servlet Engines
          ●   Sun Java web Server, JigSaw Server by W3C,
              Netscape Eneterprise Server, Lotus Domino Go Server




6                                                   Ashish Bhatia
Understanding a Bit here

●   Add – on servlet Engines
      ●   Jserv [ Apache ]
      ●   JRun [ Live Software ]
      ●   WebSphere [ IBM ]
      ●   ServletExec [ Atlantas ]

●   Embeddable Servlet Engines




7                                    Ashish Bhatia
Coming back to HTTP

●   Always client initiates a transaction by establishing a
     connection and sending HTTP request.
●   Server has no way to callback or connect client.
●   HTTP transaction begins with :
      ●   Request from the client browser.
      ●   Ends with Response from the server.
●   Request Header consist of three parts
      ●   Method – URI – Protocol Version
      ●   Request Headers
      ●   Entity Body


8                                                   Ashish Bhatia
Coming back to HTTP




9                     Ashish Bhatia
Coming back to HTTP




10                    Ashish Bhatia
Coming back to HTTP




11                    Ashish Bhatia
Coming back to HTTP




12                    Ashish Bhatia
Coming back to HTTP

●    Server process the request and send the response to
      the client.
●    HTTP/1.0 200 OK




13                                                Ashish Bhatia
Coming back to HTTP



●    1xx: Informational - Request received,
          continuing process
●    2xx: Success - The action was successfully received,
          understood, and accepted
●    3xx: Redirection - Further action must be taken in order
          to complete the request
●    4xx: Client Error - The request contains bad syntax or
          cannot be fulfilled
●    5xx: Server Error - The server failed to fulfill an
          apparently valid request

14                                                     Ashish Bhatia
Coming back to HTTP

●    GET
      ●    Retrieve information identified by Request-URI
●    HEAD
      ●    Similar to GET except that server will not return
             a message body
●    POST
      ●




15                                                   Ashish Bhatia
Coming back to HTTP

●    PUT
      ●    Enclosed entity be stored under the supplied
             Requested-URI
      ●    If entity exists it will be treated as modified version
      ●    201 – Created
      ●    200 – OK
      ●    204 – No Content
      ●    Error Code
      ●    501 – Not Implemented



16                                                     Ashish Bhatia
Coming back to HTTP

●    DELETE
      ●   Delete the resource identified by the Request-URI
      ●   200 – OK
      ●   202 – accepted
      ●   204 – No content
●    TRACE
      ●    Used to invoke a remote, application-layer
          loop-back of the request message. The final
          recipient of the request SHOULD reflect the
          message received back to the client as the
          entity-body of a 200 (OK) response.

17                                                 Ashish Bhatia
Coming back to HTTP

●    CONNECT
       ●   Reserves for use with proxy that can dynamically
             switch to being a tunnel.




18                                                Ashish Bhatia
Prepared using




Are You Attentive ?

How many methods we studied ?

How request header looks ?

How response header looks ?


     Lets move to Servlet Basics


19                                        Ashish Bhatia
Servlet Application Architecture

●    A servlet is a Java class that can be loaded dynamically
         into and run by a special web server.
●    Servlet Container / Servlet Engine :
         Servlet aware web server




20                                                  Ashish Bhatia
Servlet Application Architecture

●    Problem and Solution




21                                 Ashish Bhatia
How Servlet Works

●    Servlet is loaded in Servlet
      Container first.
●    Servlet then is forwared the
      user request, process it,
      and returns the response
      to the servlet container
      which in turns send response
      back to server.
●    Servlet stays in memory
      waiting for other requests
●    Unloaded ??? Shortage of mem

22                                   Ashish Bhatia
Tomcat as Servlet Container

●    Designed by Sun Microsystem
●    Handed the code the Apache – 1999
       ●   Included as Jakarta Project
       ●   Its one of recognised Servlet Container and
              used world wide
       ●   OpenSource
●    Current version 7.0




23                                                  Ashish Bhatia
Getting up with Tomcat

●    Genreally two options available for
         tomcat installation
      ●   Liked by many .exe
      ●   Zip folder
●    Where to get Tomcat ?
      ●   http://tomcat.apache.org/
      ●   http://tomcat.apache.org/download-70.cgi
●




24                                                   Ashish Bhatia
Getting up with Tomcat




25                       Ashish Bhatia
Setting up using zip / tar.gz version

●    Setting up on any platform
         ●   Extract the zip / tar.gz to desired place
              ●   Assumption
                   ●   Extracted folder D:tomcat
                   ●   JDK : C:Program FilesJavajdk
         ●   Set two environment variables
              ●   CATALINA_HOME=D:tomcat
              ●   JAVA_HOME=C:Program FilesJavajdk
●    If exe :
     ●   Double click ==> Get installed as window service


26                                                       Ashish Bhatia
Moving ahead to directory




27                          Ashish Bhatia
Directory details

●    bin
     ●   Contains files for starting / stopping tomcat server
●    conf
         ●   Contains xml files
●    lib
         ●   Contains jar files
●    logs
●    temp
●    webapps
         ●   Working directory mapped to localhost [ see later ]
●    work
28                                                      Ashish Bhatia
Program Structure

                       Project

                                        JSP pages,
WEB-INF                                 static html pages,
                                        applet classes


              classes             lib              tags


 web.xml       .class files   Library archives     . tag files


29                                               Ashish Bhatia
Directory details

●    Http://localhost:8080/Add
      ●   This will call up index page
            [Default Page]
      ●   When called the servlet object
           is created from Add.class




30                                         Ashish Bhatia
Understanding the javax.servlet




31                                Ashish Bhatia
Understanding the javax.servlet : interfaces

●    14 interfaces : 7 implemented provided by container
     ●   ServletConfig
     ●   ServletContext
     ●   ServletRequest
     ●   ServletResponse
     ●   RequestDispatcher
     ●   FilterChain
     ●   FilterConfig




32                                                Ashish Bhatia
Understanding the javax.servlet : interfaces

●    14 interfaces : 7 left for developer
     ●   Servlet
     ●   ServletRequestListener
     ●   ServletRequestAttributeListener
     ●   ServletContextListener
     ●   ServletContextAttributeListener
     ●   SingleThreadModel
     ●   Filter




33                                             Ashish Bhatia
ServletContext

●    ServletConfig interface
      ●   getServletContext() that returns ServletContext
●    Communicates with the container when you want to
      perform actions such as writing log files or
      dispatching request
●    One ServletContext object per web application.
      ●   Intialized when application starts
      ●   Destroyed when application shut downs
●    Persistence mechanism
      ●   Attributes available through out.


34                                                  Ashish Bhatia
Other interfaces brief introduction

●    ServletRequest and ServletResponse
      ●   Provide the client request information and object
            used to send the reponse to the client.
●    RequestDispatcher
      ●   Object that manages client request by directing them
            to appropriate resources to the server.
●    Filter, FilterChain, FilterConfig
      ●   Use for filtering




35                                                  Ashish Bhatia
Understanding the javax.servlet : classes
●    Nine classes + 2 exception classes
      ●   Generic Servlet
      ●   ServletContextEvent
      ●   ServletContextAttributeEvent
      ●   ServletRequestEvent
      ●   ServpetRequestAttributeEvent
      ●   ServletInputStream
      ●   ServletOutputStream
      ●   ServletRequestWrapper
      ●   ServletResponseWrapper
      ●   ServletException
      ●   UnavailableException
36                                          Ashish Bhatia
Understanding the javax.servlet : classes




37                                          Ashish Bhatia
Understanding the javax.servlet : classes




38                                          Ashish Bhatia
Serlvet Interface : LifeCycle
●    Servlet must implement the Servlet interface OR
      Extend from a class that has already implemented
      Servlet Interface.
●    public void init(ServletConfig c) throws ServletException
●    public void service(ServletRequest req, ServletResponse
      res) throws ServletException, IOException
●    public void destroy()

●    public ServletConfig getServletConfig()
●    public String getServletInfo() throws ServletException,
      IOException


39                                                  Ashish Bhatia
GenericServlet Class
●    Abstract class implmenting Servlet Interface.
     ●   public void init(ServletConfig config)
     ●   public void init()
     ●   public abstract void service(ServletRequest req,
           ServletResponse res)
     ●   public void destroy()
     ●   public ServletContext getServletContext()
     ●   public java.util.Enumeration getInitParameterNames()
     ●   public String getInitParameter(String name)
     ●   public String getServletName()
     ●   public void log(String msg)
     ●   public void log(String message, java.lang.Throwable t)
40                                                     Ashish Bhatia
HttpServlet Cass
●    Overrides service method of GenericServlet class.
     ●   public void init(ServletConfig config)
     ●   public void init()
     ●   public void service(ServletRequest req,
           ServletResponse res)
     ●   public void service(HttpServletRequest req,
           HttpServletResponse res)


public void destroy()




41                                                     Ashish Bhatia
HttpServlet Cass
●    protected void doGet(HttpServletRequest req,
      HttpServletResponse res) throws ServletException,
      IOException
●    protected void doPost(HttpServletRequest req,
      HttpServletResponse res) throws ServletException,
      IOException
●    protected void doHead(HttpServletRequest req,
      HttpServletResponse res) throws ServletException,
      IOException
●    protected void doPut(HttpServletRequest req,
      HttpServletResponse res) throws ServletException,
      IOException

42                                              Ashish Bhatia
HttpServlet Cass
●    protected void doOption(HttpServletRequest req,
      HttpServletResponse res) throws ServletException,
      IOException
●    protected void doTrace(HttpServletRequest req,
      HttpServletResponse res) throws ServletException,
      IOException
●    protected long getLastModified(HttpServlet req)
      throws ServletException,IOException




43                                               Ashish Bhatia
Understanding GenericServlet and HttpServlet




44                                        Ashish Bhatia
Program Structure

                      HelloWorld

                                     index.html
WEB-INF


               classes         lib


 web.xml    HelloWorld.class


29                                         Ashish Bhatia
Prepared using




End of Session for today

More Related Content

What's hot

Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
Hadoop
HadoopHadoop
HDFS Design Principles
HDFS Design PrinciplesHDFS Design Principles
HDFS Design Principles
Konstantin V. Shvachko
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
DrSonali Vyas
 
Hadoop hive presentation
Hadoop hive presentationHadoop hive presentation
Hadoop hive presentation
Arvind Kumar
 
Introduction to HBase
Introduction to HBaseIntroduction to HBase
Introduction to HBase
Avkash Chauhan
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
Tomcat
TomcatTomcat
Servlets api overview
Servlets api overviewServlets api overview
Servlets api overview
ramya marichamy
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
kamal kotecha
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
Venkata Naga Ravi
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
Computer Hardware & Trouble shooting
 
File Management – File Concept, access methods, File types and File Operation
File Management – File Concept, access methods,  File types and File OperationFile Management – File Concept, access methods,  File types and File Operation
File Management – File Concept, access methods, File types and File Operation
Dhrumil Panchal
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
Jafar Nesargi
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna
 
Introducing Technologies for Handling Big Data by Jaseela
Introducing Technologies for Handling Big Data by JaseelaIntroducing Technologies for Handling Big Data by Jaseela
Introducing Technologies for Handling Big Data by Jaseela
Student
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Rich internet application (ria)
Rich internet application (ria)Rich internet application (ria)
Rich internet application (ria)
TAInteractive
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
Manisha Keim
 

What's hot (20)

Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Hadoop
HadoopHadoop
Hadoop
 
HDFS Design Principles
HDFS Design PrinciplesHDFS Design Principles
HDFS Design Principles
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Hadoop hive presentation
Hadoop hive presentationHadoop hive presentation
Hadoop hive presentation
 
Introduction to HBase
Introduction to HBaseIntroduction to HBase
Introduction to HBase
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Tomcat
TomcatTomcat
Tomcat
 
Servlets api overview
Servlets api overviewServlets api overview
Servlets api overview
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
File Management – File Concept, access methods, File types and File Operation
File Management – File Concept, access methods,  File types and File OperationFile Management – File Concept, access methods,  File types and File Operation
File Management – File Concept, access methods, File types and File Operation
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Introducing Technologies for Handling Big Data by Jaseela
Introducing Technologies for Handling Big Data by JaseelaIntroducing Technologies for Handling Big Data by Jaseela
Introducing Technologies for Handling Big Data by Jaseela
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Rich internet application (ria)
Rich internet application (ria)Rich internet application (ria)
Rich internet application (ria)
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 

Similar to Http and Servlet basics

slides (PPT)
slides (PPT)slides (PPT)
slides (PPT)
webhostingguy
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
reeder29
 
Apache web service
Apache web serviceApache web service
Apache web service
Manash Kumar Mondal
 
Apache tomcat
Apache tomcatApache tomcat
Apache tomcat
Shashwat Shriparv
 
Progressive web applications
Progressive web applicationsProgressive web applications
Progressive web applications
Tom Martin
 
Philly Tech Fest Iis
Philly Tech Fest IisPhilly Tech Fest Iis
Esigate dev meeting 25 03_2013
Esigate dev meeting 25 03_2013Esigate dev meeting 25 03_2013
Esigate dev meeting 25 03_2013
nricheton
 
Webserver
WebserverWebserver
Webserver
ARYA TM
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
WebStackAcademy
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
webhostingguy
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
Andy Bunce
 
Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Servers
webhostingguy
 
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.pptweb-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
20521742
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
Bob Killen
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
David Newman
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with Nginx
Bud Siddhisena
 
Servlet classnotes
Servlet classnotesServlet classnotes
Servlet classnotes
Vasanti Dutta
 
Webinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientWebinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP Client
Knoldus Inc.
 
12.+Managing+Containers.pdf
12.+Managing+Containers.pdf12.+Managing+Containers.pdf
12.+Managing+Containers.pdf
VikrantSChohaan
 
ChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy IntroChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy Intro
ChinaNetCloud
 

Similar to Http and Servlet basics (20)

slides (PPT)
slides (PPT)slides (PPT)
slides (PPT)
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
 
Apache web service
Apache web serviceApache web service
Apache web service
 
Apache tomcat
Apache tomcatApache tomcat
Apache tomcat
 
Progressive web applications
Progressive web applicationsProgressive web applications
Progressive web applications
 
Philly Tech Fest Iis
Philly Tech Fest IisPhilly Tech Fest Iis
Philly Tech Fest Iis
 
Esigate dev meeting 25 03_2013
Esigate dev meeting 25 03_2013Esigate dev meeting 25 03_2013
Esigate dev meeting 25 03_2013
 
Webserver
WebserverWebserver
Webserver
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013BaseX user-group-talk XML Prague 2013
BaseX user-group-talk XML Prague 2013
 
Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Servers
 
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.pptweb-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
web-servers3952 (1)qwjelkjqwlkjkqlwe.ppt
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with Nginx
 
Servlet classnotes
Servlet classnotesServlet classnotes
Servlet classnotes
 
Webinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP ClientWebinar: Draw a line between HTTP/2 client and HTTP Client
Webinar: Draw a line between HTTP/2 client and HTTP Client
 
12.+Managing+Containers.pdf
12.+Managing+Containers.pdf12.+Managing+Containers.pdf
12.+Managing+Containers.pdf
 
ChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy IntroChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy Intro
 

More from AshishSingh Bhatia

Servlet Event framework
Servlet Event frameworkServlet Event framework
Servlet Event framework
AshishSingh Bhatia
 
Servlet Filter
Servlet FilterServlet Filter
Servlet Filter
AshishSingh Bhatia
 
JSP : Creating Custom Tag
JSP : Creating Custom Tag JSP : Creating Custom Tag
JSP : Creating Custom Tag
AshishSingh Bhatia
 
Dom Basics
Dom BasicsDom Basics
Dom Basics
AshishSingh Bhatia
 
Java script
Java scriptJava script
Java script
AshishSingh Bhatia
 
Java I/O Part 2
Java I/O Part 2Java I/O Part 2
Java I/O Part 2
AshishSingh Bhatia
 
Java I/O Part 1
Java I/O Part 1Java I/O Part 1
Java I/O Part 1
AshishSingh Bhatia
 
Nested and Enum Type in Java
Nested and Enum Type in JavaNested and Enum Type in Java
Nested and Enum Type in Java
AshishSingh Bhatia
 

More from AshishSingh Bhatia (8)

Servlet Event framework
Servlet Event frameworkServlet Event framework
Servlet Event framework
 
Servlet Filter
Servlet FilterServlet Filter
Servlet Filter
 
JSP : Creating Custom Tag
JSP : Creating Custom Tag JSP : Creating Custom Tag
JSP : Creating Custom Tag
 
Dom Basics
Dom BasicsDom Basics
Dom Basics
 
Java script
Java scriptJava script
Java script
 
Java I/O Part 2
Java I/O Part 2Java I/O Part 2
Java I/O Part 2
 
Java I/O Part 1
Java I/O Part 1Java I/O Part 1
Java I/O Part 1
 
Nested and Enum Type in Java
Nested and Enum Type in JavaNested and Enum Type in Java
Nested and Enum Type in Java
 

Recently uploaded

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 

Recently uploaded (20)

Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 

Http and Servlet basics

  • 1. Prepared using Unit 2 HTTP Basics Servlet Basics Presentation by AshishSingh T Bhatia Lecturer, CTI ast.bhatia@gmail.com
  • 2. Assignment 1 1. Explain Internet and WWW. 2. Explain the basic structure of HTML document with brief history. 3. What is JavaScript? Describe its evolution. 4. Explain different type of datatypes available and use in JS. 5. Write shortnote on DOM. 6. List and explain different browsers objects. 7. Explain all form elements. 8. List and explain JavaScript Event handlers. 9. Explain in detail Form Object and its use. 10. Explain inbuilt objects in JavaScript. [ String and Date] I Ashish Bhatia
  • 3. Assignment 1 11. Explain the functions and its use in JavaScript. 12. Explain following with examples 1. typeof 2. instanceof 3. prototype 4. constructor 5. caller 6. toString 7. valueOf 13. Desribe the object creation in JavaScript with example. II Ashish Bhatia
  • 4. HTTP ● HTTP stands for Hyper Text Transfer Protocol HTTP/0.9 HTTP/1.0 HTTP/1.1 RFC ? RFC 1945 RFC 2616 ● HTTP is ● Aplication Level Protocol for distributed, collaborative, hypermedia information systems. ● Generic stateless protocol which can be used for many tasks beyond its use for hypertext . ● Use by WWW since 1990. ● Use reliable TCP / IP connection. 1 Ashish Bhatia
  • 5. URL , URI , URN ● URL : Uniform Resource Locator ● URI : Uniform Resource Identifier ● URN : Uniform Resource Name 2 Ashish Bhatia
  • 6. URL , URI , URN ● Web Identifiers ● Classical View ● [ URI ] Identifier might specify ● location of resource ==> URL ● http:// ● identifies a resource via a representation of its primary access mechanism (e.g., its network "location"), ● Its name independent of location ==> URN ● urn:isbn :n-nn-nnnnnn-n 3 Ashish Bhatia
  • 7. Move Back to History 4 Ashish Bhatia
  • 8. Move Back to History 5 Ashish Bhatia
  • 9. Understanding a Bit here ● Take place of CGI scripts ● Run inside a JVM [ Making it safe and portable ] ● Operate solely in domain of server unlike applet they do not require support for Java on web Browser. ● Efficient and Scalable : Threads are used for request. ● Support for servlet ● Standalone Servlet Engines ● Sun Java web Server, JigSaw Server by W3C, Netscape Eneterprise Server, Lotus Domino Go Server 6 Ashish Bhatia
  • 10. Understanding a Bit here ● Add – on servlet Engines ● Jserv [ Apache ] ● JRun [ Live Software ] ● WebSphere [ IBM ] ● ServletExec [ Atlantas ] ● Embeddable Servlet Engines 7 Ashish Bhatia
  • 11. Coming back to HTTP ● Always client initiates a transaction by establishing a connection and sending HTTP request. ● Server has no way to callback or connect client. ● HTTP transaction begins with : ● Request from the client browser. ● Ends with Response from the server. ● Request Header consist of three parts ● Method – URI – Protocol Version ● Request Headers ● Entity Body 8 Ashish Bhatia
  • 12. Coming back to HTTP 9 Ashish Bhatia
  • 13. Coming back to HTTP 10 Ashish Bhatia
  • 14. Coming back to HTTP 11 Ashish Bhatia
  • 15. Coming back to HTTP 12 Ashish Bhatia
  • 16. Coming back to HTTP ● Server process the request and send the response to the client. ● HTTP/1.0 200 OK 13 Ashish Bhatia
  • 17. Coming back to HTTP ● 1xx: Informational - Request received, continuing process ● 2xx: Success - The action was successfully received, understood, and accepted ● 3xx: Redirection - Further action must be taken in order to complete the request ● 4xx: Client Error - The request contains bad syntax or cannot be fulfilled ● 5xx: Server Error - The server failed to fulfill an apparently valid request 14 Ashish Bhatia
  • 18. Coming back to HTTP ● GET ● Retrieve information identified by Request-URI ● HEAD ● Similar to GET except that server will not return a message body ● POST ● 15 Ashish Bhatia
  • 19. Coming back to HTTP ● PUT ● Enclosed entity be stored under the supplied Requested-URI ● If entity exists it will be treated as modified version ● 201 – Created ● 200 – OK ● 204 – No Content ● Error Code ● 501 – Not Implemented 16 Ashish Bhatia
  • 20. Coming back to HTTP ● DELETE ● Delete the resource identified by the Request-URI ● 200 – OK ● 202 – accepted ● 204 – No content ● TRACE ● Used to invoke a remote, application-layer loop-back of the request message. The final recipient of the request SHOULD reflect the message received back to the client as the entity-body of a 200 (OK) response. 17 Ashish Bhatia
  • 21. Coming back to HTTP ● CONNECT ● Reserves for use with proxy that can dynamically switch to being a tunnel. 18 Ashish Bhatia
  • 22. Prepared using Are You Attentive ? How many methods we studied ? How request header looks ? How response header looks ? Lets move to Servlet Basics 19 Ashish Bhatia
  • 23. Servlet Application Architecture ● A servlet is a Java class that can be loaded dynamically into and run by a special web server. ● Servlet Container / Servlet Engine : Servlet aware web server 20 Ashish Bhatia
  • 24. Servlet Application Architecture ● Problem and Solution 21 Ashish Bhatia
  • 25. How Servlet Works ● Servlet is loaded in Servlet Container first. ● Servlet then is forwared the user request, process it, and returns the response to the servlet container which in turns send response back to server. ● Servlet stays in memory waiting for other requests ● Unloaded ??? Shortage of mem 22 Ashish Bhatia
  • 26. Tomcat as Servlet Container ● Designed by Sun Microsystem ● Handed the code the Apache – 1999 ● Included as Jakarta Project ● Its one of recognised Servlet Container and used world wide ● OpenSource ● Current version 7.0 23 Ashish Bhatia
  • 27. Getting up with Tomcat ● Genreally two options available for tomcat installation ● Liked by many .exe ● Zip folder ● Where to get Tomcat ? ● http://tomcat.apache.org/ ● http://tomcat.apache.org/download-70.cgi ● 24 Ashish Bhatia
  • 28. Getting up with Tomcat 25 Ashish Bhatia
  • 29. Setting up using zip / tar.gz version ● Setting up on any platform ● Extract the zip / tar.gz to desired place ● Assumption ● Extracted folder D:tomcat ● JDK : C:Program FilesJavajdk ● Set two environment variables ● CATALINA_HOME=D:tomcat ● JAVA_HOME=C:Program FilesJavajdk ● If exe : ● Double click ==> Get installed as window service 26 Ashish Bhatia
  • 30. Moving ahead to directory 27 Ashish Bhatia
  • 31. Directory details ● bin ● Contains files for starting / stopping tomcat server ● conf ● Contains xml files ● lib ● Contains jar files ● logs ● temp ● webapps ● Working directory mapped to localhost [ see later ] ● work 28 Ashish Bhatia
  • 32. Program Structure Project JSP pages, WEB-INF static html pages, applet classes classes lib tags web.xml .class files Library archives . tag files 29 Ashish Bhatia
  • 33. Directory details ● Http://localhost:8080/Add ● This will call up index page [Default Page] ● When called the servlet object is created from Add.class 30 Ashish Bhatia
  • 35. Understanding the javax.servlet : interfaces ● 14 interfaces : 7 implemented provided by container ● ServletConfig ● ServletContext ● ServletRequest ● ServletResponse ● RequestDispatcher ● FilterChain ● FilterConfig 32 Ashish Bhatia
  • 36. Understanding the javax.servlet : interfaces ● 14 interfaces : 7 left for developer ● Servlet ● ServletRequestListener ● ServletRequestAttributeListener ● ServletContextListener ● ServletContextAttributeListener ● SingleThreadModel ● Filter 33 Ashish Bhatia
  • 37. ServletContext ● ServletConfig interface ● getServletContext() that returns ServletContext ● Communicates with the container when you want to perform actions such as writing log files or dispatching request ● One ServletContext object per web application. ● Intialized when application starts ● Destroyed when application shut downs ● Persistence mechanism ● Attributes available through out. 34 Ashish Bhatia
  • 38. Other interfaces brief introduction ● ServletRequest and ServletResponse ● Provide the client request information and object used to send the reponse to the client. ● RequestDispatcher ● Object that manages client request by directing them to appropriate resources to the server. ● Filter, FilterChain, FilterConfig ● Use for filtering 35 Ashish Bhatia
  • 39. Understanding the javax.servlet : classes ● Nine classes + 2 exception classes ● Generic Servlet ● ServletContextEvent ● ServletContextAttributeEvent ● ServletRequestEvent ● ServpetRequestAttributeEvent ● ServletInputStream ● ServletOutputStream ● ServletRequestWrapper ● ServletResponseWrapper ● ServletException ● UnavailableException 36 Ashish Bhatia
  • 40. Understanding the javax.servlet : classes 37 Ashish Bhatia
  • 41. Understanding the javax.servlet : classes 38 Ashish Bhatia
  • 42. Serlvet Interface : LifeCycle ● Servlet must implement the Servlet interface OR Extend from a class that has already implemented Servlet Interface. ● public void init(ServletConfig c) throws ServletException ● public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException ● public void destroy() ● public ServletConfig getServletConfig() ● public String getServletInfo() throws ServletException, IOException 39 Ashish Bhatia
  • 43. GenericServlet Class ● Abstract class implmenting Servlet Interface. ● public void init(ServletConfig config) ● public void init() ● public abstract void service(ServletRequest req, ServletResponse res) ● public void destroy() ● public ServletContext getServletContext() ● public java.util.Enumeration getInitParameterNames() ● public String getInitParameter(String name) ● public String getServletName() ● public void log(String msg) ● public void log(String message, java.lang.Throwable t) 40 Ashish Bhatia
  • 44. HttpServlet Cass ● Overrides service method of GenericServlet class. ● public void init(ServletConfig config) ● public void init() ● public void service(ServletRequest req, ServletResponse res) ● public void service(HttpServletRequest req, HttpServletResponse res) public void destroy() 41 Ashish Bhatia
  • 45. HttpServlet Cass ● protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException ● protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException ● protected void doHead(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException ● protected void doPut(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException 42 Ashish Bhatia
  • 46. HttpServlet Cass ● protected void doOption(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException ● protected void doTrace(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException ● protected long getLastModified(HttpServlet req) throws ServletException,IOException 43 Ashish Bhatia
  • 47. Understanding GenericServlet and HttpServlet 44 Ashish Bhatia
  • 48. Program Structure HelloWorld index.html WEB-INF classes lib web.xml HelloWorld.class 29 Ashish Bhatia
  • 49. Prepared using End of Session for today