08 January 2021

#Servlet

#Servlet
What is different between web server and application server?
What is MIME Type?
What is a web application and what is its directory structure?
What is a servlet?
What are the advantages of Servlet over CGI?
What are common tasks performed by Servlet Container?
What is ServletConfig object?
What is ServletContext object?
What is Request Dispatcher?
What is the use of servlet wrapper classes?
What is SingleThreadModel interface?
What is the inter-servlet communication?
What is servlet attributes and their scope?
What are the phases of servlet life cycle?
What are life cycle methods of a servlet?
What is URL Encoding?
What are different methods of session management in servlets?
What is URL Rewriting?
What is the effective way to make sure all the servlets are accessible only when user has a valid session?
What is a deployment descriptor?
What are important features of Servlet 3?
What are different ways for servlet authentication?
Write a servlet to upload file on server.
Why HttpServlet class is declared abstract?
why we should override only no-agrs init() method.
Why do we have servlet filters?
Why do we have servlet listeners?
Which HTTP method is non-idempotent?
How can we create deadlock situation in servlet?
How do we call one servlet from another servlet?
How can we invoke another servlet in a different application?
How does Cookies work in Servlets?
How to notify an object in session when session is invalidated or timed-out?
How to handle exceptions thrown by application with another servlet?
How to make sure a servlet is loaded at the application startup?
How to get the actual path of servlet in server?
How to get the server information in a servlet?
How do we go with database connection and log4j integration in servlet?
How to get the IP address of client in servlet?
How can we achieve transport layer security for our web application?
Difference - GET and POST method?
Difference - ServletConfig and ServletContext?
Difference - PrintWriter and ServletOutputStream?
Difference - GenericServlet and HttpServlet?
Difference - ServletResponse sendRedirect() and RequestDispatcher forward() method?
Difference - encodeRedirectUrl and encodeURL?
Are Servlets Thread Safe? How to achieve thread safety in servlets?
Can we get PrintWriter and ServletOutputStream both in a servlet?
Do we need to override service() method?
Is it good idea to create servlet constructor?
  • It is a technology which is used to create a web application.
  • It is an API that provides many interfaces and classes including documentation.
  • It is an interface that must be implemented for creating any Servlet.
  • It is a class that extends the capabilities of the servers and responds to the incoming requests. It can respond to any requests.
  • It is a web component that is deployed on the server to create a dynamic web page.
  • A war (web archive) File : It contains files of a web project. It may have servlet, xml, jsp, image, html, css, js etc. files.
LifeCycle
  • Servlet class is loaded.
  • Servlet instance is created.
  • init method is invoked.
  • service method is invoked.
  • destroy method is invoked.
  • The welcome-file-list element of web-app, is used to define a list of welcome files.
  • Its sub element is welcome-file that is used to define the welcome file.
  • A welcome file is the file that is invoked automatically by the server, if you don't specify any file name.
Interfaces in javax.servlet package
  • Servlet - ServletRequest, ServletResponse
  • RequestDispatcher
  • ServletConfig
  • ServletContext
  • SingleThreadModel
  • Filter - FilterConfig, FilterChain
  • ServletRequestListener
  • ServletRequestAttributeListener
  • ServletContextListener
  • ServletContextAttributeListener
Classes in javax.servlet package
  • GenericServlet
  • ServletInputStream
    • It provides stream to read binary data such as image etc. from the request object.
    • It is an abstract class.
    • getInputStream()- ServletRequest interface returns the instance of ServletInputStream class.
  • ServletOutputStream
    • It provides a stream to write binary data into the response. It is an abstract class.
    • The getOutputStream() method of ServletResponse interface returns the instance of ServletOutputStream class.
  • ServletRequestWrapper & ServletResponseWrapper
  • ServletRequestEvent & ServletContextEvent
  • ServletRequestAttributeEvent & ServletContextAttributeEvent
  • ServletException
  • UnavailableException
Interfaces in javax.servlet.http package
  • HttpServletRequest & HttpServletResponse
  • HttpSession
  • HttpSessionListener
  • HttpSessionAttributeListener
  • HttpSessionBindingListener
  • HttpSessionActivationListener
  • HttpSessionContext (deprecated now)
Classes in javax.servlet.http package
  • HttpServlet
  • Cookie - Cookie remains active as long as the user?s browser is running, as soon as the browser is closed, the cookie and associated session info is destroyed
  • HttpServletRequestWrapper & HttpServletResponseWrapper
  • HttpSessionEvent
  • HttpSessionBindingEvent
  • HttpUtils (deprecated now)
Points to remember
  • Web application
  • Implicit objects
  • JSP directives
  • Server - Web, Application
  • MIME Type
  • The Hypertext Transfer Protocol (HTTP) - Requests, Responses
  • HTTP method - Get, Post, Put, Head, Delete, Options
  • HTTPServletRequest & HTTPServletResponse
  • Servlet - Lifecycle, Servlet container
  • GenericServlet & HttpServlet
  • Deployment descriptor
  • War File
  • welcome-file-list
  • Load on startup
  • ServletConfig object& ServletContext object
  • Event and Listener
  • Servlet Collaboration - RequestDispacher, sendRedirect
  • Filter - Authentication Filter, FilterConfig
  • Request Dispatcher - Send Redirect vs. Forward
  • URL Encoding & URL Rewriting
  • Inter servlet communication
  • Cookies & Session - Create, Read, Update, Delete
  • SingleThreadModel interface
  • Servlet attributes - Scope
  • encodeRedirectUrl and encodeURL
  • Servlet wrapper classes
  • PrintWriter and ServletOutputStream
  • Localization
  • Servlet Invoker
  • Servlet lazy loading
  • Servlet Chaining
  • Servlet mapping
  • PageAutoRefresh

No comments:

Post a Comment

Most views on this month