Week6 Flashcards

1
Q

What is HTTP?

A

An application layer protocol in the internet protocol suite model for distributed hypermedia information.

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

What is HTTP used for?

A

It is a protocol that is used for fetching resources such as HTML documents. It is the foundation of ANY exchange on the Web.

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

HTTP is a client-server protocol. T/F?

A

True.

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

What is The Method Attribute used for?

A

This is used to specify the HTTP method used to send data while submitting the form.

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

Two options in The Method Attribute?

A

GET and POST.

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

What is a GET?

A

Part of The Method Attribute.

After submission of the form, the form values will be visible in the address bar of the browser.

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

What is a POST?

A

Part of The Method Attribute.

After submission of the form, the form values will NOT be visible in the address bar of the browser.

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

What does it mean for an HTTP verb to be idempotent?

A

It means an identical request can be made once or several times in a row with the same effect while leaving the server in the same state. It should not have any side-effects.

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

Explain The Value Attribute.

A

Specifies an initial value for an input field. It also serves as the attribute to use when providing a button label for submit and reset input elements.

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

Explain the placeholder Attribute.

A

Specifies a hint that describes the expected value of the input field (a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.

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

Explain the required attribute.

A

It indicates an input field that must be filled out before submitting the form. In most modern browsers, it will prevent the user from submitting the form until an acceptable value is entered.

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

Explain the min and max attributes.

A

The min and max attributes specify the minimum and maximum values for an input field.

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

Explain the Action attribute.

A

It indicates where the form data will be processed. Typically the value is a URL of a server. Generally, the form data is sent to a webpage on the webserver after the user clicks on the submit button.

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

Explain the Target Attribute.

A

This is used to specify whether the submitted result will open in the current window, a new tab or on a new frame. The default value used is “self” which results in the form submission in the same window. To make the result display in a new browser tab, the value should be set to “blank”.

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

Explain the Name Attribute.

A

The name attribute should be provided for each input element. It is not required, but the value provides a label for the data once the form is submitted. If the name attribute is not specified in an input field then the data of that field will not be sent.

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

What is HTML form?

A

This is a section of a document that contains controls such as text fields, password fields, checkboxes, radio buttons, submit button, menus, etc. Using these elements the page can collect information from a user which is typically submitted to a web server.

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

Why use an HTML Form?

A

We use forms to collect some information/data form the user.

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

What are the contents of an HTTP request?

A

HTTP version
URL
HTTP verb / method
Request Headers
Request Body

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

What are the contents of an HTTP response?

A

HTTP response contents
HTTP version
Status code
Response Headers
Response Body

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

What is a URL?

A

Uniform Resource Locator. The address of a given unique resource on the Web.

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

What is an HTTP request header?

A

An HTTP header that can be used in an HTTP request to provide information about the request context, so that the server can tailor the response.

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

What is a servlet?

A

A Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Commonly used to extend the applications hosted by web servers.

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

What is a servlet container?

A

These control servlets. When an application running in a web server receives a request, the Server hands the request to the Servlet Container - which in turn passes it to the target servlet.

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

Name the 4 parts to the servlet hierarchy in order from top to bottom.

A

Servlet interface.
Generic servlet.
Http servlet.
MyServlet.

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

Explain the servlet interface.

A

The servlet interface of the javax.servlet package defines methods that the Web container calls to manager the servlet life cycle.

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

Explain public void destroy()

A

The Web container calls the destroy() method just before removing the servlet instance from service.

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

What are the three life cycle methods of a Servlet?

A

init()
service()
destroy()

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

What are the 5 steps in the servlet life cycle in order?

A
  1. Loading of Servlet.
  2. Creating an instance of Servlet.
  3. Invoke init() method once.
  4. Invoke service() method repeatedly for each client request.
  5. Invoke destroy() method once.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Explain the first step of the Servlet Life Cycle, Loading of Servlet.

A

When the application server (ex. Apache Tomcat) starts up, the servlet conatiner deploys and loads all the servlet classes.

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

Explain the 2nd step of the Servlet Life Cycle, Creating an instance of Servlet.

A

Once all the Servlet classes are loaded, the servlet container creates only one instance for each servlet class.

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

Explain the 3rd step of the Servlet Life Cycle, Invoke init() method once.

What is the init() method signature?

A

Once all the servlet classes are instantiated, the init() method is invoked for each instantiated servlet. The init() method is used to initialize the servlet. The init() method is called only once.

public void init() throws ServletException {
}

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

Explain the 4th step of the Servlet Life Cycle, Invoke service() method repeatedly for each client request.

What is the service method signature?

A

The servlet container calls the service method each time a request for the servlet is received. The service() method determines the type of Http request (GET, POST, PUT, DELETE, etc.) also calls doGet(), doPost(), doPut(), doDelete(), etc. methods as appropriate.

public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
}

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

Explain the 5th step of the Servlet Life Cycle, Invoke destroy() method once.

What is the destroy() method signature?

A

The destroy() method is called only once at the end of the a servlet’s life. The servlet container calls this method before removing the servlet instance from the service.

public void destroy() {
}

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

What are the 6 steps to creating a servlet using the HttpServlet class approach?

A
  1. Create a directory structure
  2. Create a Servlet
  3. Compile the Servlet
  4. Create a deployment descriptor
  5. Start the server and deploy the project, configure Tomcat.
  6. Access the Servlet.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

What is the directory structure?

A

This defines where to put the different types of files so that the Web container may get the information and respond to the client.

36
Q

What are the three ways to create a servlet? Which is the most common?

A
  1. By implementing the Servlet interface.
  2. By inheriting the GenericServlet class.
  3. By inheriting the HttpServlet class.

Inheriting the HttpServlet class.

37
Q

Why is the HttpServlet class the most common way to create a Servlet?

A

Because it provides methods to handle http request such as doGet(), doPost, doHead() etc.

38
Q

Which file is required for compiling the Servlet?

A

the .jar file.

39
Q

What is the deployment descriptor?

A

This is an xml file from which the Web Container gets the information about the servlet to be invoked.

40
Q

Two tasks to configure Apache Tomcat Server?

A
  1. set JAVA_HOME or JRE_HOME in environment variable (It is required to start server).
  2. Change the port number of tomcat (optional). It is required if another server is running on same port (8080).
41
Q

What is Lazy Loading?

A

The practice of delaying load or initialization of resources or objects until they’re actually needed to improve performance and save system resources.

42
Q

What are some benefits of lazy loading?

A

Reduces initial load time.
Bandwidth conservation.
System resource conservation.

43
Q

What is Eager loading?

A

The practice of loading resources as soon as the code is executed.

44
Q

What is the default loading type for servlets?

A

Lazy Loading is default.

45
Q

What is the difference between ServletConfig and ServletContext?

A

An object containing some initial parameters or configuration information created by Servlet Container and passed to the servlet during initialization.

The object created by Servlet Container to share initial parameters or configuration information to the whole application.

46
Q

What is the RequestDispatcher Interface?

A

This provides the facility of dispatching the request to another resource it may be html, servlet or jsp.

47
Q

What are the two methods provided by the RequestDispatcher interface?

A
  1. ) public void forward(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException
  2. ) public void include(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException
48
Q

This methods forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server.

A

public void forward(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException

49
Q

This method includes the content of a resource (servlet, JSP page, or HTML file) in the response.

A

public void include(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException

50
Q

Explain the difference between RequestDispatcher.forward() and HttpServletResponse.sendRedirect()

A

Redirection is a type of response sent back to the client, whereas the forward delegation takes place completely on the server side and the result of the forward action returns to the client as if it came only from the original URL.

51
Q

What is Object Mapping?

A

The ability to establish a correspondence between objects belonging to heterogeneous models and diagrams.Do this to setup a structure for data movement and transformation.

52
Q

What is the difference between getParameter() and getAttribute() methods?

A

Returns http request parameters. Those passed from the client to the server.

This is for server-side usage only - you fill the request with attributes that you can use within the same request.

53
Q

What is REST?

A

Representational state transfer is a software architectural style that was created to guide the design and development of the architecture for the World Wide Web. REST defines a set of constraints for how the architecture of an Internet-scale distributed hypermedia system, such as the Web, should behave.

54
Q

What is a REST Resource?

A

A vital element to be referenced within a client-server system. REST architecture treats all of its content as a resource.

Two of the most popular are JSON and XML.

55
Q

What are the guiding principles of REST?

A
  1. Uniform Interface.
  2. Client-Server
  3. Stateless
  4. Cacheable
  5. Layered System
  6. Code on Demand.
56
Q

What does it mean for a REST API to be stateless?

A

This means that every HTTP request happens in complete isolation. When the client makes an HTTP request, it includes all information necessary for the server to fulfill the request.

57
Q

What is the Richardson Maturity Model and what are the levels?

A

A four level scale that indicates extent of API conformity to the REST fraemwork.

Four levels (top to bottom) —
HyperMedia
HTTP
URI
POX Swamp

58
Q

What is HATEOAS?

A

Hypermedia As The Engine Of Application State.

This is a constraint of the REST application architecture that distinguishes it from other network application architectures.

59
Q

R

An application layer protocol in the internet protocol suite model for distributed hypermedia information.

A

What is HTTP?

60
Q

R

This is used to specify the HTTP method used to send data while submitting the form.

A

What is The Method Attribute used for?

61
Q

R

Part of The Method Attribute.

After submission of the form, the form values will be visible in the address bar of the browser.

A

What is a GET?

62
Q

R

Part of The Method Attribute.

After submission of the form, the form values will NOT be visible in the address bar of the browser.

A

What is a POST?

63
Q

R

It means an identical request can be made once or several times in a row with the same effect while leaving the server in the same state. It should not have any side-effects.

A

What does it mean for an HTTP verb to be idempotent?

64
Q

R

Specifies an initial value for an input field. It also serves as the attribute to use when providing a button label for submit and reset input elements.

A

Explain The Value Attribute.

65
Q

R

Specifies a hint that describes the expected value of the input field (a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.

A

Explain the placeholder Attribute.

66
Q

R

It indicates an input field that must be filled out before submitting the form. In most modern browsers, it will prevent the user from submitting the form until an acceptable value is entered.

A

Explain the required attribute.

67
Q

R

It indicates where the form data will be processed. Typically the value is a URL of a server. Generally, the form data is sent to a webpage on the webserver after the user clicks on the submit button.

A

Explain the Action attribute.

68
Q

R

This is used to specify whether the submitted result will open in the current window, a new tab or on a new frame. The default value used is “self” which results in the form submission in the same window. To make the result display in a new browser tab, the value should be set to “blank”.

A

Explain the Target Attribute.

69
Q

R

This is a section of a document that contains controls such as text fields, password fields, checkboxes, radio buttons, submit button, menus, etc. Using these elements the page can collect information from a user which is typically submitted to a web server.

A

What is HTML form?

70
Q

R

A Java programming language class that is used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. Commonly used to extend the applications hosted by web servers.

A

What is a servlet?

71
Q

R

init()
service()
destroy()

A

What are the three life cycle methods of a Servlet?

72
Q

R

When the application server (ex. Apache Tomcat) starts up, the servlet conatiner deploys and loads all the servlet classes.

A

Explain the first step of the Servlet Life Cycle, Loading of Servlet.

73
Q

R

Once all the Servlet classes are loaded, the servlet container creates only one instance for each servlet class.

A

Explain the 2nd step of the Servlet Life Cycle, Creating an instance of Servlet.

74
Q

R

Once all the servlet classes are instantiated, the init() method is invoked for each instantiated servlet. The init() method is used to initialize the servlet. The init() method is called only once.

public void init() throws ServletException {
}

A

Explain the 3rd step of the Servlet Life Cycle, Invoke init() method once.

What is the init() method signature?

75
Q

R

The servlet container calls the service method each time a request for the servlet is received. The service() method determines the type of Http request (GET, POST, PUT, DELETE, etc.) also calls doGet(), doPost(), doPut(), doDelete(), etc. methods as appropriate.

public void service(ServletRequest req, ServletResponse resp) throws ServletException, IOException {
}

A

Explain the 4th step of the Servlet Life Cycle, Invoke service() method repeatedly for each client request.

What is the service method signature?

76
Q

R

The destroy() method is called only once at the end of the a servlet’s life. The servlet container calls this method before removing the servlet instance from the service.

public void destroy() {
}

A

Explain the 5th step of the Servlet Life Cycle, Invoke destroy() method once.

What is the destroy() method signature?

77
Q

R

This defines where to put the different types of files so that the Web container may get the information and respond to the client.

A

What is the directory structure?

78
Q

R

This is an xml file from which the Web Container gets the information about the servlet to be invoked.

A

What is the deployment descriptor?

79
Q

R

The practice of delaying load or initialization of resources or objects until they’re actually needed to improve performance and save system resources.

A

What is Lazy Loading?

80
Q

R

The practice of loading resources as soon as the code is executed.

A

What is Eager loading?

81
Q

R

An object containing some initial parameters or configuration information created by Servlet Container and passed to the servlet during initialization.

The object created by Servlet Container to share initial parameters or configuration information to the whole application.

A

What is the difference between ServletConfig and ServletContext?

82
Q

R

This provides the facility of dispatching the request to another resource it may be html, servlet or jsp.

A

What is the RequestDispatcher Interface?

83
Q

R

  1. ) public void forward(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException
  2. ) public void include(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException
A

What are the two methods provided by the RequestDispatcher interface?

84
Q

R

public void forward(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException

A

This methods forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server.

85
Q

R

public void include(ServletRequest request,ServletResponse response)throws ServletException,java.io.IOException

A

This method includes the content of a resource (servlet, JSP page, or HTML file) in the response.

86
Q

R

The ability to establish a correspondence between objects belonging to heterogeneous models and diagrams.Do this to setup a structure for data movement and transformation.

A

What is Object Mapping?