The _________ method of a servlet is called once, indicating that the servlet is being placed into service.
- destroy()
- doGet()
- init()
- service()
The init() method of a servlet is called once, indicating that the servlet is being placed into service for initialization purposes.
What method is commonly used to send a redirect response to the client in servlets?
- forwardResponse()
- redirectResponse()
- sendForward()
- sendRedirect()
The sendRedirect() method is commonly used in servlets to send a redirect response to the client, specifying the new URL to which the client should be redirected.
Which of the following is a Java class that extends the capabilities of the servers?
- Applet
- JSP
- JavaBean
- Servlet
A Servlet is a Java class that extends the capabilities of servers, providing a way to generate dynamic content on the web.
What is the maximum size of data that can be sent using the GET method in a servlet?
- 2 GB
- 256 KB
- Limited by server configuration
- No specific limit
There is no specific limit imposed by the HTTP specification on the size of data that can be sent using the GET method. However, practical limitations may exist, and server configurations can impose their own limits.
A developer needs to implement complex business logic with minimal HTML. Should they choose Servlet or JSP?
- Both
- JSP
- None of the above
- Servlet
When implementing complex business logic with minimal HTML, Servlets are more suitable as they provide better control over the business logic, separating it from the presentation layer. JSP is better for the view layer and is commonly used for creating dynamic web pages with embedded Java code.
A ________ request can be cached by the browser, whereas a ________ request cannot.
- GET; POST
- GET; PUT
- POST; DELETE
- POST; PUT
A GET request can be cached by the browser, whereas a POST request cannot be cached.
What object is primarily used to read form data in a servlet?
- FormReader
- HttpRequest
- HttpServletRequest
- ServletRequest
The HttpServletRequest object is primarily used to read form data in a servlet.
When handling file uploads in a servlet, the __________ utility class from Apache Commons FileUpload can be used.
- FileParser
- FileReader
- FileUpload
- FileWriter
When handling file uploads in a servlet, the FileUpload utility class from Apache Commons FileUpload is commonly used for parsing and processing multipart/form-data requests, including file uploads.
In a servlet, to get an array of all the values of a multi-valued parameter, use the __________ method.
- getArrayValues()
- getMultiValuedParameter()
- getParameterValues()
- retrieveParameterArray()
The getParameterValues() method in a servlet is used to get an array of all the values of a multi-valued parameter.
Cookies used for tracking user sessions are typically called _________ cookies.
- Persistent
- Secure
- Session
- Tracking
Cookies used for tracking user sessions are typically called Session cookies.