- What is a servlet?
- What does a web server do?
- What are the important headers that are sent through HTTP Request Format?
- User Agent (gives the info about the browser we are using)
- Acceptance Language (specifies what language is acceptable to the client)
- Describe a brief about status codes in HTTP Response Format?
100 - 199 ---> Information
200 - 299 ---> Success
300 - 399 ---> Redirect
400 - 499 ---> Requested Resource not available.
500 - 599 ---> Failed to execute the requested resource.
- What does Content Type specifies in a servlet program?
- What is the difference between "doGet()" and "doPost()" methods?
- Draw the folder structure of a web based project?
- Why WEB-INF folder is called as a private folder?
- What are the important classes and interfaces in Servlets?
- Describe Deployment descriptor?
In any web-based applications, we call "web.xml" file as deployment descriptor. This is because, when ever we deploy the project, server first searches for the web.xml file. Server reads the data in it and keeps in JVM.
- What happens if the .class file is not present in the classes folder?
- What are the parameters that are supplied to service() method?
- When will we get the exception "illegal access specifier"
- In how many ways we can write a servlet program?
- By implementing Servlet Interface
- By extending GenericServlet Class
- By extending HttpServlet Class
It is recommended to use HttpServlet, so that we can reduce the amount of code.
- How can we remove hard coding in Servlet programming?
We can removing Hard coding in Servlet programming by using Servlet Context and Servlet Config. We can supply the values to Servlet Context and Servlet Config through deployment descriptor(web.xml file).
- What happens when multiple clients try to access a single servlet?
When Multiple clients try to access one servlet, only one servlet object will be created and this object is shared between multiple clients.
- What is Thread Pool? What is its use?
Thread Pool is a program that starts whenever a servlet is started. When a client sends the request to the server, servlet pics a thread from Thread Pool and create request and response objects. These two objects are supplied to service( ). After the server has finished its work, server will remove request and response objects and it returns the thread to the Thread Pool. By using Thread Pool, Multiple clients can access a single Servlet at a time.
- Can we have constructor in a servlet?
Yes, we can have only default constructor. We cannot have parametrized constructor.
- Why we cannot have parameterized constructor in Servlets?
Every servlet uses class.forName() to create servlet object. When we have a parameterized constructor, class.forName() will fail to create an object. It throws an exception java.lang.instantiation exception.
- Can we call destroy() method from service()?
Yes, we can call. When we call destroy() from service(), every time server executes service() it will call destroy().
No comments:
Post a Comment