6. REST Web Services

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Q - Which @Annotation must be added before the class definition when creating a Spring Boot REST controller?

@RestController

Q - Which of the following JSON objects contain an array?

Anything contained within [] brackets, even if it's a single object.

Q - What does AJAX stand for?

Asynchronous JavaScript and XML

Q - What is true of both XML and JSON?

Both are human readable.

Q - How can you add and remove CSS classes on an HTML element using jQuery?

By using the addClass() and removeClass() functions on the selected HTML element.

Q - How can you remove an HTML element using jQuery?

By using the remove() function on the selected element.

Q - How can an HTML element be shown and hidden with jQuery?

By using the show() and hide() functions on the selected element.

Q - How can you create + update an HTML element using jQuery?

Create: append() - Inserts content at the end of the selected elements prepend() - Inserts content at the beginning of the selected elements after() - Inserts content after the selected elements before() - Inserts content before the selected elements Update: The val() function The html() function The text() function

Q - How is data returned from a REST API call? How is it passed to a REST web service?

Data is returned in the ResponseBody. Data is passed through the RequestBody or the URL.

Q - (T/F) JSON formatted data always begins with a root tag.

False

Q - What are some examples of HTTP status codes?

Here are some examples of HTTP status codes along with their general meanings: 200 OK - The request was successful and the response contains the requested data. 201 Created - The request was successful and a new resource has been created. 204 No Content - The request was successful, but there is no data to return in the response. 400 Bad Request - The request was malformed or invalid and could not be processed. 401 Unauthorized - The request requires authentication or the provided credentials are invalid. 403 Forbidden - The request is not authorized to access the requested resource. 404 Not Found - The requested resource could not be found on the server. 500 Internal Server Error - An unexpected error occurred on the server while processing the request. 502 Bad Gateway - The server acting as a gateway or proxy received an invalid response from an upstream server. 503 Service Unavailable - The server is temporarily unavailable, often due to maintenance or overload. 418: I'm a teapot, although an April Fools joke, does exist.

Q - What is REST? What does it stand for?

It is a design approach for building web services. Representational State Transfer

Q - What is true about JSON?

It is a serialization format. It is text-based.

Q - What is the $ symbol in jQuery?

It is an alias for the jQuery function.

Q - What is the standard way in which the 'action' of a REST endpoint is specified?

It is specified by the HTTP method used.

Q - What is the purpose of the first + second callback function specified for the hover event?

It is the code that should be run when the mouse starts + stops hovering over the element. $(selector).hover(over, out); where over is the callback function that is executed when the mouse pointer enters the element, and out is the callback function that is executed when the mouse pointer leaves the element.

Q - What is an endpoint?

It is the combination of a URL and an HTTP method.

Q - What is the purpose of only running our code after the document ready event has fired?

It prevents unpredictable and undefined behavior in our code.

Q - Which of the following statements are true about Spring Initializr?

It provides support for Maven. It generates a project zip file. It's a web-based app that helps create a Spring Boot project structure.

Q - Why was XMLHttpRequest invented?

It was invented by Microsoft to support web access to Outlook mail servers.

Q - What are some advantages of using JDBCTemplate over JDBC?

JDBCTemplate helps prevent SQL injection attacks. JDBCTemplate simplifies exception handling. JDBCTemplate makes it easier to work with database transactions.

Q - What best describes JSON?

JSON uses key/value pairs or just values to format and represent data.

Q - What are valid HTTP Request Methods?

POST GET DELETE PUT

Q - When using JDBC template, what class must be implemented to map data from the database into an object in Java?

RowMapper

Q - How do we tell the web service that we want it to send JSON data back to us after it process our request?

Set the Accept header to application/json.

Q - What are differences between the traditional web application model and the Ajax web application model?

Some application logic can reside in the client in the Ajax model, whereas all of the application logic resides on the server in the traditional model.

Q - What must be known in order to interact with a REST endpoint?

The URL The HTTP Method

Q - What does the first + second parameter of the on() function specify?

The event name for which you are registering. The code that you want to run in response to the event.

Q - What is serialization?

The process of encoding object data so it can be transferred or stored

Q - How do we specify the callback functions to be run upon completion of our jQuery ajax call?

The success and error key/value pairs in the ajax function parameter set.

Q - What can be used to update the content of input elements?

The val() function

Q - When using JDBC template and creating the application.properties file, what three properties must be included to make a connection to a database?

Username & password URL to your database

Q - How are HTML elements selected using jQuery?

Using CSS selector syntax. jQuery provides a number of ways to select HTML elements based on various criteria. Here are some common ways to select elements using jQuery: Select by tag name: You can select all elements with a specific tag name using the $('tagname') syntax. For example, $('p') selects all p elements on the page. Select by class name: You can select all elements with a specific class name using the $('.classname') syntax. For example, $('.myclass') selects all elements with the class myclass. Select by ID: You can select an element with a specific ID using the $('#idname') syntax. For example, $('#myid') selects the element with the ID myid. Select by attribute: You can select all elements with a specific attribute using the $('tagname[attribute]') syntax. For example, $('a[href]') selects all a elements with

Q - How do we tell the web service that we'll be sending JSON data as part of our request when using the jQuery ajax function to make a POST request?

We set the Content-Type headers to application/json.

Q - What are technologies used in Ajax?

XMLHTTPRequest JSON XML

Q - What is XMLHttpRequest (XHR)?

XMLHttpRequest is an API that allows JavaScript code to exchange data with web services over HTTP and HTTPS.

Q - What is NOT a common web service data format?

eXtensible Code Markup

Q - After creating a jdbc object with the following code: @Autowired Private JdbcTemplate jdbc; What method can you use to send an SQL insert command to the database?

update


संबंधित स्टडी सेट्स

Combinatorics, Probability, & Factorials

View Set

Chapter 27: Chest Injuries (Questions)

View Set

Tutorials point - java interview

View Set

Alternating Current Module 25: AC Circuits Dynamic Study Module

View Set

Chapter 18 Federal Judiciary Practice Test

View Set

Fundamental Chapter 9: Teaching and Counseling

View Set

Geology 103 Lessons 4 & 5--Midterm

View Set

INF 43: Introduction to Software Engineering

View Set

STUDY GUIDE EXAM 1 (SLIGHTLY LESS incomp)

View Set

Chapter 3: Nursing Practice and the Law, NCLEX - Legal & Ethical, Nursing Jurisprudence: Legal and Ethical Considerations NCLEX Practice Quiz, Legal and Ethical Issues in Nursing, NCLEX Questions-Ethical and Legal Issues, NCLEX STYLE REVIEW QUESTIONS...

View Set