JEE Flashcards

1
Q

Describe a servlet

A

A servlet is a small java program that runs inside a web server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe GenericServlet

A

GenericServlet is a protocol-indepent Servlet which contains the service method, with other helper methods that log and gather information about the application and servlet configuration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the Servlet interface

A

The Servlet is a simple interface that contains methods for initializing and destroying the Servlet, as well as servicing requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe two ways in which request parameters come

A
  1. Query parameters, also known as URI parameters e.g. GET /index.jsp?productId = 45845545&category=Books
  2. or multipart/form data
    e.g POST /index.jsp?returnTo=product page
    Host : www.example.com
    Content-Length: 48
    Content-type: application/x-www-form-urlencoded
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

doDelete() is responsible for _

A

doDelete() is responsible for deleting the resource at the specified URL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

doGet() is responsible for _

A

doGet() is responsible for retrieving the resource at the specified URL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

doHead() is responsible for _

A

doHead() is responsible for retrieving the resource at the specified URL, but only headers are returned

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

doOptions() returns _

A

doOptions() returns which HTTP methods are allowed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

doPost() is typically used for _

A

doPost() is typically used for web form submission

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

doPut() _

A

doPut() stores the supplied entity at the URL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

doTrace() is used for _

A

doTrace() is responsible for diagnostic purposes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

For responding to _ requests, the javax.servlet.http.HttpServlet _ GenericServlet, and implements the _ method to accept only HTTP requests

A

For responding to HTTP-specific requests, the javax.servlet.http.HttpServlet extends GenericServlet, and implements the service method to accept only HTTP request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you instruct tomcat to start the servlet immediately when the web application starts

A

you do this by configuring the web.xml with the following:

1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The _ interface is an extension of ServletRequest that provides additional _ information about a received request.

A

The HttpServletRequest interface is an extension of ServletRequest that provides additional HTTP protocol-specific information about a received request. It specifies dozens of methods that can be used to obtain details about an HTTP request, eg HttpServletRequest request.getContextPath();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True or False, as of Java EE7, the only Servlet protocol currently supported is HTTP

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

True or False, every servlet implements the javax.servlet.Servlet interface?

A

true

17
Q

True or False, in almost all cases, Servlet inherit from java.servlet.GenericServlet

A

True

18
Q

True or False, you should always use the destroy method to clean up resources held up by your Servlet between requests

A

True

19
Q

What are the responsibilities of a servlet

A

A servlet receives and responds to requests from web clients, usually across HTTP

20
Q

what does the deployment descriptor do?

A

the deployment descriptor instructs the web container how the application should be deployed

21
Q

What is the most important capability of the HttpServletRequest?

A

The most important capability of the HttpServletRequest is to retrieve parameters passed by the client

22
Q

When is the destroy method called?

A

The destroy method is called when the web application is stopped or undeployed, or when the web container shuts down

23
Q

When is the init method called?

A

The init method is called when the Servlet starts:

  1. if the servlet is configured to start automatically when the web application is deployed and started, that is when it is called
  2. otherwise it is called after the first request for the servlet is received