Arquivo da categoria: HTTP

Notes About Spring e Retrofit

Which of the following are true statements about the Retrofit library?
It can be used to provide strong typing for interactions with HTTP-based cloud services
It can automatically marshall Java objects into HTTP request bodies

Which of the following are reasons to use dependency injection?
To reduce the amount of manually written configuration code that is needed to "wire" an application together
To help decouple one or more classes from their dependencies

What is @Autowired used for?
To indicate that one or more of a class' dependencies should be automatically provided through dependency injection

Which of the following are true of object relational mapping?
It is used to aid in persisting instances of Java objects into a database

Which of the following statements are true of the code shown below:

@RequestMapping("/some/path")
public @ResponseBody List<Video> findVideos(@RequestParam("title") String videoTitle){
String query = "select * from video where video.title = '"+videoTitle+"'";
return executeDatabaseQuery(query)
}

@RequestParam will NOT filter the title parameter and the code could suffer from an SQL injection attack
Arbitrary logic could potentially be injected into the query

Which of the following are true of Spring JPA Repositories?
The implementations of repository interfaces are automatically created by Spring

Enjoy
Marcos Carvalho

Notes about Spring Dispatcher

Which of the following are true of Java annotations?
They can be used to provide metadata for methods and other Java constructs.

 

Which of the following are true statements regarding the Spring DispatcherServlet?
It is used to route requests to Spring Controller objects.
It can invoke different methods on a Controller object depending on the request path.

 

Which of the following are uses of the @RequestBody annotation?
To indicate to Spring that the body of an incoming HTTP request should be unmarshalled to provide the value for a parameter of a method annotated with @RequestMapping.

 

@RequestParam can be used if the HTTP request has a multipart body.

 

Which of the following are true of @ResponseBody?
@ResponseBody helps to decouple Controller method logic from HTTP-specific protocol details.
@ResponseBody indicates that the return value from a Controller method should be used to produce the body of the HTTP response.

 

Which of the following are true statements about an Application class, such as the Application class in the examples?
It can be used to provide configuration information to Spring.
It does not have to inherit from a Spring-specific super class.
With Spring Boot and the appropriate annotations, it can be used to setup a Dispatcher servlet.
It can provide a main() method to launch Spring Correct.

 

Which of the following are true statements about JSON?
It can be used to express the state of a Java object.
It can be used to express arrays of objects.
It is a text-based format.

 

Enjoy
Marcos Carvalho

Notes About HTTP and Servlets

Which of the following are correct statements regarding HTTP polling?
Since a client does not have direct access to any server-side state, the client may waste resources by polling the server for updates when there are none.
Dynamically adapting the polling interval is one approach to reducing unnecessary HTTP requests.
Polling can generate excess load on a server if the polling interval is too short.

 

Which of the following are true of Push Messaging?
If the state that needs to be pushed to a client is extremely sensitive, a "push to poll" model where the server sends a push notification and then the client polls for a state update is most appropriate
If the state that needs to be pushed to a client is extremely large (e.g., multiple megabytes), a "push to poll" model where the server sends a push notification and then the client polls for a state update is most appropriate
Push messaging relies on a persistent connection between a mobile device and a push messaging system's servers

 

Which of the following are true statements about Servlets?
A servlet has doXXXX methods for each type of request method that can be sent to the server

 

Which of the following is true about handling client input data in a servlet?
A servlet can access url encoded parameters placed in the body of a request sent by a client
A servlet can access URL query parameters sent by a client

 

Which of the following are true statements regarding request routing and servlets?
A web.xml file can be used to specify which requests should be routed to which servlets
Requests can be routed to different servlets based on the resource path specified in the request

 

Which of the following could lead to an injection attack?
Failing to verify that the type of data sent to the server is what was expected
Storing client-provided data without filtering it and then resending it to other clients
Allowing client-provided data to control an execution path involving sensitive data
Echoing executable client-provided data back to the client without filtering it

 

Which of the following are true statements regarding client-provided data?
None of the below are correct:

  • Careful filtering of client-provided data is not needed if only one type of client is expected to ever use a cloud service
  • Careful filtering of client-provided data is not needed if the same developer writes the mobile client and the cloud service
  • Because client-provided data is so hard to filter, a cloud service should never accept a body in an HTTP request
  • Client-provided data in URL query parameters is always safer than the same data provided in a URL encoded request body

 

Enjoy
Marcos de Carvalho Oliveira

Notes About Protocol and HTTP

What are the components of a protocol?
Semantics
Syntax
Timing

 

What is HTTP?

A communication protocol that is based on a client/server model
A communication protocol commonly used by web browsers

 

What are some of the reasons that HTTP is commonly used for mobile to cloud communication?
There is significant existing investment and infrastructure for HTTP communication

 

What are HTTP request methods?
An indication of an action that a client would like the server to apply to a resource

 

Which of the following are possible components of an HTTP request?
A Content-type for a body included with the request
Headers
A Request Body
Request Line

 

What is URL encoding?
An alternative representation of certain characters that can be placed in a URL

 

What is the purpose of the content-type header?
To tell either the client or server the format of the data included in a request or response body

 

What is the purpose of the numeric code included in the status line of an HTTP response?
To provide an indication of what happened when the server processed the request

 

Which of the following are possible outcomes of a request that a server could indicate with a 2XX response code?
The request was successfully processed

 

Which of the following are true of cookies?
They are small pieces of data that the server indicates should be included by the client in future requests

 

Enjoy
Marcos Carvalho