1) What is Servlet?
It is a technology used to create web applications.
It is a web component which is used to create dynamic web pages.
It consists of many interfaces and classess such as Servlet, HttpServlet, GenericServlet, ServletRequest, ServletResponse etc.
2) What are the advantages of Servlet?
Advantages of Servlet are:
- Secure
- Robust
- Portable
- Better performance
3) What are the types of Http request methods?
Http request methods are:
- Get
- Post
- Head
- Trace
- Put
- Delete
- Option
4) What are the types of Servers?
Two types of servers are:
- Web server
- Application server
5) What are the features provided by MIME(Multipurpose Internet Mail Extension) to the Email Service?
Features of MIME to the Email Service are:
- Supports non -ASCII characters
- Attach multiple files in a single message
- Supports unlimited message length
- Supports attachment like executable audio, video, and image files etc
6) What are the types of Content types used in Servlet?
Types of Content types are :
text/html
text/plain
application/msword
application/vnd.ms-excel
application/jar
application/pdf
images/jpeg
images/png
images/gif
audio/mp3
video/mp4 etc.
7) What are the methods of Servlet interface?
Methods of Servlet interface are:
public void destroy()
public String getServletInfo()
public void init(ServletConfig config)
public ServletConfig getServletConfig()
public void service(ServletRequest request,ServletResponse response)
8) What are the types of ways for session tracking?
Four ways of session tracking are:
Cookies
URL Rewriting
HttpSession
Hidden form field
9) What are the methods of Cookie class?
Methods of Cookie class are:
public String getName()
public String getValue()
public void setName(String name)
public void setValue(String value)
public void setMaxAge(int expiry)
10) What are common tasks performed by Servlet Container?
Tasks performed by Servlet Container are:
Communication Support
Lifecycle and Resource Management
Multithreading Support
JSP Support etc.
11) How to create a cookie in Servlet?
Example of create a cookie in Servlet:
Cookie ck=new Cookie("user","TutorialandExample");
response.addCookie(ck);
12) What is the life cycle of a Servlet?
Life cycle of a Servlet:
- Step 1: Servlet is loaded
- Step 2: Servlet is instantiated
- Step 3: Servlet is initialized
- Step 4: Service the request
- Step 5: Servlet is destroyed
13) Which event is fired at the time of session creation and destroy?
At the time of session creation and destroy, The
HttpSessionEvent is fired.
14) How can we perform any action at the time of deploying the project?
With the help of
ServletContextListener interface, We can perform any action at the time of deploying the project.
15) When Servlet object is created?
Servlet object is created at the time of
First Request.