Javalin Flashcards

1
Q

What is Javalin?

A
  • Lightweight framework for Java (and Kotlin) to handle HTTP requests and responses.
    • It runs on an embedded server (Jetty)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Jetty? What is the relationship between Jetty and Javalin?

A

-Jetty is an opensource, embedded web server, and Java servlet container.. Javalin runs on top of Jetty.
Allows you to manage and execute servers as well as restrict access to system resources.

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

What are servlets and how are they related to Javalin.

A

Servlet is a java program that runs inside JVM on the web server. It is used for developing dynamic web applications . it does the same jobs as a server. Javalin is a servlet container that allows servlet applications to be ran on. A servlet is portable, efficient and scalable, and robust.

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

What is object mapping?

A

Converting java classes to JSON objects and vice versa. Jackson binding Is the tool that Javalin uses in order to complete object mapping via JSON parsing.

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

How does Javalin convert JSON data to Java objects? And the other way around?

A

Javalin converts JSON data to Java objects by using Jackson binding.

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

What are HTTP handlers in Javalin?

A

The HTTP handler is a Java component that consists of properties. The handlerdelivers an outbound integration message to a URL by using HTTP or HTTPS protocols. The HTTP handler also evaluates the response code received from the external system.

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

What are different ways to set up HTTP handlers

A

Java handlers can be set up Before handlers, at the Endpoint handlers, and After handlers. They all require 3 parts, a verb, a path, and a handler implementation.

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

What are handler groups?

A

handler groups of Javalin include before-handlers, endpoint-handlers, and after-handlers. They require a verb, a path, and a handler implementation.
Before-handlers are matched before every request.
Endpoint handlers define your API.
And after-handlers run after every request.

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

What is the context object? What is it an abstraction of?

A

Context objects provides you with everything you need to handle a http-request. It contains the underlying servlet-request and servlet-response, and a bunch of getters and setters. It is an abstraction of the http request and http response.

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

How would you handle path parameters?

A

ctx.pathParam([path name string]);

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

How would you handle query params?

A

ctx.queryParam(“key”);

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

How would you retrieve the request body

A

ctx.body();

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

How would you map an endpoint?

A

App.verb

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

What methods could you use to return information in the response body?

A

bodyasstring(), .bodyasbytes(), .bodyasclass().

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

How would you set a status code for a response?

A

ctx.status(404);

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