Summary

This document contains a set of multiple choice question and answers related to web application development. The questions cover topics including programming languages (Java, Javascript, Typescript), frameworks (Spring, Angular), databases (JDBC) and various web technologies.

Full Transcript

## Spring - AOP (Aspect Oriented Programming) is one of Spring's features, and consists in associating actions with methods (functions), actions performed automatically and which can be specified outside of the code with which they are associated. - It offers advanced mechanisms for managing the se...

## Spring - AOP (Aspect Oriented Programming) is one of Spring's features, and consists in associating actions with methods (functions), actions performed automatically and which can be specified outside of the code with which they are associated. - It offers advanced mechanisms for managing the security of a web application. - In Spring managing an object of type EntityManager can be done automatically by the container. - SpringBoot can be used to automatically generate Spring applications. - The DI (Dependency Injection) mechanism allows the automatic creation of objects by the container. ## Angular - Programs written in JavaScript are translated through compilation into TypeScript and vice versa. - An Angular application is stored at the client, it is transferred automatically from the client to the server, it is executed on the server, the generated HTML being displayed in the browser. - The official language for developing Angular applications is TypeScript. - TypeScript is a procedural language and not an object-oriented one. - Even a TypeScript code that contains errors can be translated through compilation into JavaScript code, but not vice versa. ## JDBC - Operations performed with Statement can only receive parameters if they perform queries. - With a ResultSet object that contains a set of records, the value from a record can be obtained based on the name of the column corresponding to the table. - To perform a query, you can use Statement but not PreparedStatement. - Operations performed with PreparedStatement can receive parameters. - PreparedStatement can be used to perform add, delete, update operations. ## Servlets - The invocation of a servlet involves calling a method on a container object of a type derived from HttpServlet. - A servlet can process (receive) requests of type GET as well as POST. - A servlet is a Java class that extends HttpServlet. - Servlet objects are created by the container or by the user. - The mapping of a servlet can be done using an annotation (directly to the code) or in the web.xml file. ## Angular - ngmodel is an Angular directive while ngfor is not an Angular directive. - An Angular component is a TypeScript class. - An Angular component is used to interact with the server and to allow communication between Angular services. - The HTML corresponding to an Angular service is displayed in the user interface through the unique page of the application, the page that contains the tag <app-root>. - The decorator of an Angular component is an annotation. ## jHipster - jHipster uses SpringBoot to generate web applications that contain backend and frontend. - With jHipster, you can generate web applications with Angular frontend but not React. - jHipster offers features for generating and configuring related to security mechanisms. - jHipster is a generator of professional applications that are based on Java and with which you can build monolithic and microservices web application. - The JDL language is an integral part of jHipster and allows the description of JPA entities and the relationships between them. ## Sessions and cookies - Cookies are created on the server and stored on the client (in the browser). - Any session has an ID but the cookie corresponding to the session does not have to contain the ID. - Sessions can be managed using only the URL override. - Sessions can be managed using cookies. - Cookies are sent from the server to the client or vice versa being attached to the HTTP response or request. ## JDBC - A JDBC--ODBC driver is a driver that allows, at least theoretically, connecting to any database that complies with the SQL standard. - To connect to a database, a Java-based application needs a JDBC--ODBC driver or a dedicated JDBC driver. - Java SE (Standard Edition) applications can connect to databases but also need Java web libraries. - Web applications that are based on the Java language can connect to databases using JPA or only JDBC. ## JSP - The errorPage attribute specifies whether the current JSP page is an error handling page. - The @page directive can be used to import libraries but also to use sessions in a JSP page. - A scriptlet is a section of HTML code in a JSP page, a section delimited by <% and %>. - An expression tag is a way to display the value of a Java variable/expression in the generated HTML using <%= %> - The incorrect pairing of some <% %> tags leads first of all to a compilation error of the JSP page. ## MVC architecture - An HttpServletRequest request (object) can have attributes (objects) attached (added) to it, which have a unique label. - A JSP is used in a MVC application as View, but in a non-MVC application can also perform Controller functions. - The role of a Controller is to process the data from the HTTP request, update the Model, select the View component, and generate the HTML response. - A Java class with get/set methods for each member data and no explicit constructor is a correct JavaBean. - JavaBean objects can be created implicitly (automatically) by a container in the visibility domains mentioned by the programmer. For example, using a JSP tag. ## HTTP protocol - The HTTP protocol is a protocol that can be above the UDP protocol. - An HTTP client/server connection is of request/response type, but not necessarily independent of another connection from the protocol's point of view. - The HTTP protocol is a protocol over TCP/IP. - An HTTP client/server connection is independent of another HTTP client/server connection from the protocol's point of view. - The HTTP protocol is programmed in HTML. ## JSP file - The execution of a JSP file is ultimately reduced to the execution of a method on the corresponding servlet object. - A servlet is translated into a JSP file. - The translation process is carried out at each access of the JSP file. - The compilation process is carried out at each access of the JSP file. - The execution time of the JSP file is shorter if the JSP has been accessed previously. ## JPA entities - An entity class must have the @Entity annotation and must be a JavaBean class. - The names of the data members of an entity class can coincide with the names of the columns of the corresponding table. - An object of the type of an entity class corresponds to a table in the database. - If the name of the entity class does not coincide with the name of the associated table, then the latter must be specified in the @Table annotation - An entity class maps to a record from a database table ## JPQL - A JPQL query can contain create, delete, update instructions, even though these operations could be performed with an EntityManager object. - JPQL syntax is similar to SQL but different. - A NamedQuery type JPQL query can receive parameters with names, but it cannot receive positional parameters. - JPQL allows writing native SQL queries. - JPQL queries are executed through an object of type EntityManager. ## JPA entity manager and transaction - Explicit transactions are managed by the container/server. - Programmer-managed transactions (user) involve writing explicit begin(), commit() and/or rollback() calls. - An object of type EntityManager is associated with a persistence context and allows the management of entities (creation/update/deletion/retrieval). - EntityManager objects can be created by the programmer using an EntityManagerFactory. - A persistence context has associated with it a database (address, name, username, password, dialect) and a JPA persistence mechanism provider. ## Relationships between JPA entities - Using the cascade attribute, you can automatically delete records from a table, records associated with entity objects owned, using the owner entity object. - A OneToMany relationship can be unidirectional. - For ManyToMany association, you can use a join table in addition to the tables corresponding to the entities involved in the relationship. - The mappedBy attribute must be accompanied by the cascade attribute. - A get method (for a given member data of an entity class) annotated with OneToMany return an object set (in a Set, List, etc). ## HTTP request types - If the HTTP request is initiated from the LOCATION section of a browser then the request is of POST type. - In POST type requests the parameters can be in the header or in the body of the HTTP packet. - The POST type request is suitable for cases where the amount of data in the form is significant (large). - In a form, the HTTP request type initiated for sending to the server (mentioned in the METHOD field) can be of GET type but also POST. - In GET type requests the parameters are in the header of the HTTP packet only if the number of parameters is small. ## Sessions - Any session has a timeout set by the browser. - Sessions can be terminated (invalidate) explicitly in the code. - If a servlet receives a cookie with a session ID that does not exist on the server, it can create a new session by calling the getSession method on the HttpServletRequest object. - The getSession method called on an HttpServletRequest object returns the associated session only if it exists, or if the session does not exist, NULL. - A session is automatically invalidated by the container (server) if a request is received that does not have a cookie with the session ID attached. ## ServletContext and ServletContextListener - A ServletContext object is unique per web application but also per container. - Attributes/objects can be attached (added) to a context, each having a unique label. - ServletContextListener objects are automatically created by a servlet defined by the programmer, a servlet that is part of the web application. - Some methods of a ServletContextListener object can be invoked automatically by the container. - Multiple classes derived from ServletContextListener can be associated with a web application. ## Sessions - In Java web applications, sessions are HttpSession objects created on the server (container). - Sessions are used to be able to correlate multiple independent HTTP connections. - Objects (attributes) can be added to a session, each object having a unique label. - Any session has a unique ID that is defined and assigned by the programmer. - There can be multiple sessions in a web application.

Use Quizgecko on...
Browser
Browser