ALL >> Computer-Programming >> View Article
Servlet To Develop The Web Application Dynamically

Servlet is used to develop the web application ( web application resides at server side and creates dynamic web page).There are many interfaces and classes in the servlet API such as Servlet, GenericServlet, HttpServlet, ServletRequest, ServletResponse etc.
Before Servlet, CGI (Common Gateway Interface) scripting language was used as a server-side scripting language. But CGI was having many disadvantages .
CGI(Common Gateway Interface)
CGI technology enables the web server to call an external program and pass HTTP request information to the external program to process the request. For each request, it needs to start a new process.
Disadvantage of CGI :
1. If number of clients request increases, it takes more time for sending response.
Advance java training bangalore
2. For each request, it needs to start a process and Web server is limited to start processes.
3. It uses language which are platform dependent for example C, C++, perl.
What is Servlet?
- Servlet is a technology which is used to create web application.
- Servlet is an API(Application Programming ...
... Interface) which gives many interfaces and classes including documentations.
- Servlet is an interface that must be implemented for creating any servlet.
- Servlet is a class that extend the capabilities of the servers and respond to the request.
- Servlet is a web component which is deployed on the server to create dynamic web page.
Java course in bangalore
Advantage of Servlet
The web container creates threads for handling the multiple requests to the servlet. The basic benefits of servlet are as follows:
1.Good Performance: because it creates a thread for each request .
2.Portable:because it uses java language.
3.Robust:Servlets are managed by JVM so we don't need to worry about memory leak, garbage collection etc.
4.More Secure:because it uses java language..
Servlet Life Cycle
A servlet life cycle can be defined as the entire process from its creation to the destruction. The following are the ways followed by a servlet
- The servlet is initialized by calling the init () method.java training center bangalore
-The servlet calls service() method to process a client's request.
-The servlet is exit by calling the destroy() method.
-Finally, servlet is garbage collected by the garbage collector of the JVM.
The init() method :
The init method is invoked only once. init() is invoked when the servlet is first created, and not invoked again for each user request. So, it is used for one-time initializations
The init() method creates or loads some data that will be used throughout the life of the servlet.
The service() method :
The service() method is the main method to perform the task. The servlet container (i.e. web server) calls the service() method to handle requests coming from the user ( browsers) and to write the formatted response back to the user.java/j2ee classes bangalore
The destroy() method :
The destroy() method is called only once at the end of the life cycle of a servlet. This method gives servlet a chance to close database connections, halt background threads, write cookie lists or hit counts to disk, and perform other such cleanup activities.
After the destroy() method is called, the servlet object is marked for garbage collection.
Use Of Servlet
1) To accept form input and generate HTML Web pages dynamically.
2) As part of middle tiers in enterprise networks by connecting to SQL databases via JDBC.
3) In conjunction with applets to provide a high degree of interactivity and dynamic Web content generation.best core java training in bangalore
4) Servlets could act as active agents which share data with each other.
5)Servlets could be used for balancing load among servers
6)Protocol support
Author : Infocampus provides Advance Java Training in Bangalore with the 100% placement assistance.Attend 4 days free demo classes on java course.
Learn Oops concept,packages, thread, servlet,spring and hibernate etc. in best java training institute.Training is provided by the 10+ years experience trainers . Complete practical session is available for java training.Mock test and mock interview are conducted every weekend on java/j2ee classes.
To get the free job support call at : 9738001024 or for more information on java course in bangalore visit at : http://www.infocampus.co.in/java-training-bangalore.html
Add Comment
Computer Programming Articles
1. Unlock Your Data Skills With The Best Business Analytics Courses In BhopalAuthor: Rohan Rajput
2. Clinic Management Software: Features, Benefits, And How To Choose The Right One
Author: Agness Ruth
3. Top Training Institutes For The Best Business Analytics Courses In Bhopal
Author: Rohan Rajput
4. Why Is The Cloud Networking Solution Important For Any Business?
Author: GIGABITTechnologies
5. Pros And Cons Of Having A Design System
Author: brainbell10
6. Discover The Best Business Analytics Courses In Bhopal To Elevate Your Career
Author: Rohan Rajput
7. Exploring Decentralized Exchange Development
Author: davidbeckam
8. How Decentralized Exchanges Make Crypto Trading Better
Author: davidbeckam
9. Kiwi Web Solutions: Your Go-to Prosper Web Design Company For Exceptional Web Design In Utah
Author: Hazel Killer
10. Software Development & It Services Company Bhuj, India | Wrteam
Author: WRTeam
11. Why Choose Bhopal For Business Analytics Courses – A Career Perspective
Author: Rohan Rajput
12. Top Institutes Offering Business Analytics Courses In Bhopal
Author: Rohan Rajput
13. Learn, Launch, Lead: Digital Marketing Courses That Deliver Results”
Author: Riya Kumari
14. Have You Heard? Smart Invoice Accounting Software Is Your Best Bet For Growth
Author: Doris Rose
15. Your Guide To The Best Business Analytics Courses In Bhopal – 2025 Edition
Author: Rohan Rajput