Docsity

Java Servlet& Server side progaramming, Slides of Java Programming

Partial preview of the text

Download Java Servlet& Server side progaramming and more Slides Java Programming in PDF only on Docsity!

Disadvantages of CGI

There are many problems in CGI technology:

  • If number of clients increases, it takes more time

for sending response.

  • For each request, it starts a process and Web

server is limited to start processes.

  • It uses platform dependent language e.g. C,

C++, perl.

Advantage of Servlet

  • The web container creates threads for handling

the multiple requests to the servlet.

  • Threads have a lot of benefits over the

Processes such as they share a common

memory area, lightweight, cost of

communication between the threads are low.

The basic benefits of servlet are as follows:

  • Better performance: because it creates a thread for each request not process.
  • Portability: because it uses java language.
  • Robust: Servlets are managed by JVM so we don't need to worry about memory leak, garbage collection etc.
  • Secure: because it uses java language

Benefits of servlet

  • Portability
  • Powerful
  • Efficiency
  • Safety
  • Integration
  • Extensibility
  • Inexpensive
  • Secure
  • Performance

Anatomy of a Servlet

• init()

• destroy()

• service()

  • doGet()
  • doPost()
  • Servlet API life cycle methods
    • init(): called when servlet is instantiated; must return before any other methods will be called
    • service(): method called directly by server when an HTTP request is received; default service() method calls doGet() (or related methods covered later)
    • destroy(): called when server shuts down