Assignments for Lectures in Building Web Applications Using Java EE at Udemy.com
4. Introduction to JDBC
JDBC API is provided by _____________.
JDBC Driver is provided by ______________.
JDBC API is to be implemented by JDBC Driver. True/False
Some databases provide multiple JDBC Drivers. True/False
5. Connecting to MySQL database
____________ method of DriverManager is used to connect to database.
____________ is the object used to represent a connection to database.
____________ method is used to disconnect from database.
6. Executing DML Commands
DML stands for _________________.
Accept job id and new minimum salary and update JOBS table.
Accept job id and delete job with given id. Display error message if job id is not found.
7. Executing Query
________ method is used to move to next record in ResultSet.
If SELECT command retrieves no row, will it be an exception? True/False
Accept job id and display details of employees who are doing that job.
Accept salary from user and display employees whose salary is less than the entered salary.
8. JDBC API vs. JDBC Driver
________ interface represents a connection to database.
DriverManager.getConnection() returns an object of a class implementing Connection interface. True/False
JDBC driver is a collection of classes that provide their own API. True/False
9. Types of JDBC Drivers
How many types of JDBC drivers do we have?
If a database has no JDBC driver then we can't access it at all. True/False
________ type of driver depends on native API.
________ type of driver(s) can be used without using anything native.
10. Transaction Management
__________ method of connection object is used to start transaction.
Once a transaction is committed, it can't be rolled back. True/False
By default JDBC starts a new transaction and commits all changes as and when we execute DML command. True/False
If we start a transaction and then close connection then transaction is ______________ [committed/rolled back]
11. Using RowSet
__________ rowset is used to select data based on given predicate.
__________ method of RowSet is used to move to first row.
Can we update rows in RowSet?
Which method is used to insert a new row into a RowSet?
12. Introduction To Web Application Architecture
Java EE is an example for __________ side scripting.
_________ protocol is used to make request in web applications.
_______ is the language used for client-side scripting.
________ from google can be used to build front-end of web applications.
13. Creating a Web Application
Which folder in Eclipse project contains HTML files?
_________ is the type of project we have to create for Java EE web application in Eclipse.
_________ is the default port number at which Tomcat runs.
The name of the project is used in URL to access components in the project. True/False
14. Creating Servlets and Receiving Data from Client
________ annotation is used to specify the URL associated with Servlet.
________ method of Servlet is invoked when Http Get request is made from client.
________ method of HttpServletRequest object is used to read parameters passed from client.
________ tag is used to create a textbox in HTML form.
________ attribute of HTML form is used to specify the servlet to be invoked.
Create a Servlet that sends a random quote every time it is invoked.
Create a Servlet that takes a number as request parameter and displays its factors as bullets.
15. Difference between GET and POST requests
Data sent using GET request is passed through querystring. True/False
Which attribute of HTML form is used to specify that POST request is to be made?
Which part of HTTP request contains data when POST request is made?
Create HTML form to take age and weight from user and send it to a Servlet that displays BMI of the person.
Create Servlet that takes 4 letter PIN from user using POST request and display whether it is valid input. Input is considered to be valid if it has 4 digits. Make sure input is not visible to user at the time of entering it.
16. Servlet API and Servlet Life Cycle
___________ is the interface every Servlet must implement.
Which method in Servlet is called at the time of initializing Servlet?
Which method is called just before Servlet is removed from memory?
How do we create a Servlet without using @WebServlet annotation?
Create a Servlet that stores in a list all the numbers passed to it from request parameter number. Design it in such a way it displays all numbers sent to it when it is invoked with parameter display.
How do we pass parameters to Servlet at the time of initializing it?
17. Uploading Files from Client to Server
___________ method is used in Servlet to get access to file uploaded from client.
___________ control in HTML form is used to send file to server.
Method getRealPath() is present in ______________ interface.
What is physical path in web application and how it is different from virtual path?
Create a Servlet that takes a text file from client and displays all unique words as bullets.
18. Accessing File System from Servlet
Can we access file system of client making request from Servlet?
In order to access folder where web application is deployed, we need to use _______________ method.
When sending response to client, can we use physical path for HREF and SRC attributes of HTML tags?
Create a Servlet that takes file names.txt in data folder in root directory of web application and display all names in sorted order. Assume names.txt contains one name per line.
19. Creating JSPs
___ and _____ characters are used to enclose Java code in JSP.
Can a JSP have multiple scriptlets?
A JSP should be considered when we have more HTML to send to client and less Java code to execute. True/False
Create a JSP that takes a number and length from client and displays math table for the number upto the given length in the form of HTML table.
Create a JSP that displays first 20 Fibonacci numbers.
20. Life Cycle of JSP
________ method in JSP is equivalent to init() method in Servlet.
Whenever you run JSP, web container compiles it to bytecode. True/False
Can we say JSPs are as efficient as Servlet when it comes to execution time?
When we declare variables using JSP declaration, are variable placed inside a method or at the class level?
Create a JSP that displays messages when it is initialized and destroyed.
21. Accessing MySQL database from JSP
________ folder in web application contains JDBC driver (.jar file).
________ method is used to load JDBC driver and make it available to web application.
________ property of page directive is used to import packages and classes in JSP.
Create a JSP to display top 5 highest salaried employees.
Create a JSP to take job id as request parameter and display all employees with that job id.
22. Using JavaBeans
A JavaBean must have a constructor with ________ number of parameters.
__________ must be name of the method used to change the value of property amount.
When setProperty tag is used to assign values to JavaBean properties, which properties are considered?
What are available scopes for JavaBean?
Create a JavaBean with id and salary as properties and use this to update salary of employee.
Create a JavaBean to insert a new row into JOBS table.
23. Redirection and Navigation
What is the difference between forward() and include()?
What is the difference between client-side redirection and server-side redirection?
__________ can be used with forward action to pass additional parameters to target URL.
If we have to send an object of Customer class from one JSP to another while using forward action, where do we place the object?
How do you write code to redirect to morning.jsp if hour of the day is before 12 otherwise evening.jsp?
24. Expression Language
______ is the expression to access value of parameter amount.
What happens if we try to access a parameter in EL that is not present in the request parameters?
Can we use EL in scriptlet?
How do we refer to property price of JavaBean with id product in EL?
___________ is used to access value of user attribute of request object in EL?
When expiry date is not set for a cookie then cookie is called as ___________.
Cookie is sent back to server with every request from client. True/False
__________ method is used to get all cookies coming from client.
Write a JSP to display the value of cookie with name user if it is present otherwise redirect user to login.jsp page.
What is session timeout?
A session can be used to store data on the server about each client separately. True/False.
___________ method can be used to remove an attribute from session.
___________ method is used to terminate current session programmatically.
Create a JSP to display session id and all attributes in the session.
Create a JSP to copy all session attributes to application attributes.
Create a session attribute that stores last access datetime for a JSP and displays it everytime JSP is invoked.
27. Using JSTL Core Tags
__________ attribute of forTokens tag is used to specify separator.
How do we create an attribute in application object using set tag?
Using ______, __________ and __________ tags is similar to using switch statement.
What is the purpose of escapeXml attribute of out tag?
_________ tag is used to store exception raised in a block of code.
Write code using core tags to display all request attributes.
Write code using core tags to redirect to login.jsp if auth cookie is not found in request.
28. Using JSTL SQL and XML Tags
_______ tag is used to execute a query.
_______ is the return type of getRowsByIndex() method of Result interface.
Which method is used to get column names for the result of a query?
_______ attribute of update tag is used to obtain count of rows updated.
Create a JSP to display all rows and columns of the table whose name is passed as a parameter.
Create a JSP that inserts a row into JOBS table with values passed through request parameters.
29. Making AJAX Calls
Which object of browser is used to make asynchronous request?
Using AJAX can update a part of the page without having to redraw complete page. True/False
Which method of jQuery is used to make AJAX request?
Create HTML page to take employee id and new salary and send that data to updateSalary.jsp using AJAX request. Ensure updateSalary.jsp sends empty text on success and error message on error.
30. Sending JSON from Server
_______ method of Gson is used to convert given object to JSON.
How do we convert a CachedRowSet to an array of JSON object?
Create an HTML page that makes AJAX request to jobs.jsp whenever user clicks on a button and displays the data in a table. Send data in JSON format from jobs.jsp.
Create jobs.jsp to send jobs details as an array of JSON object. Call jobs.jsp from HTML page using AJAX and display job title as text and job id as value in a dropdownlist.
________ method in ServletContextListener is called when application is being shutdown.
How do we access session in sessionCreated() method?
Create a listener that stores list of names in Application object by taking names from names.txt file in root directly of web application.
Create a listener that writes to server console the date and time of each session's creation and termination.
________ is annotation to create a Filter.
Is it possible to associate a filter with only .html pages?
Create a filter that checks whether attribute user is present in session and if not present then redirects to login.jsp. Make sure it allows login.jsp to be called even though user is not present in session.
33. Deploying Web Application
________ folder of Tomcat contains all web applications.
________ folder contains all .jar files required by application.
A .war file contains all files related to web application including .jar files. True/False
All Servlets and JavaBeans are eventually converted to .class files. True/False