Computer Knowledge

Java Enterprise and Web Technologies

2,183 Questions

Java enterprise and web technologies questions focus on J2EE architecture, web services like SOAP, and servlet functionalities. These topics frequently appear in IT officer and specialist scale examinations. Regular practice ensures familiarity with enterprise application components.

HttpServlet methodsSOAP and web servicesEJB architecture rolesJ2EE componentsJSP servlet callingUDDI concepts

Java Enterprise and Web Technologies Questions

Multiple choice technology security
  1. LoginException

  2. EnterpriseSecurityException

  3. SecurityException

  4. IntrusionException

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The login method throws EnterpriseSecurityException, which is a custom exception specific to the security framework being used. Standard Java exceptions like LoginException, SecurityException, or IntrusionException are not the correct custom exception for this API.

Multiple choice technology security
  1. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)

  2. void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)

  3. boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)

  4. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The setNoCacheHeaders() method takes an HttpServletResponse parameter and sets cache-control headers to prevent browsers and proxies from caching sensitive content. It doesn't need HttpServletRequest, doesn't return a boolean, and doesn't throw ServletException.

Multiple choice technology security
  1. encryptHiddenField(java.lang.String value)

  2. addCSRFToken(final java.lang.String href)

  3. verifySecureComm(javax.servlet.http.HttpServletRequest request)

  4. setSafeContentType(javax.servlet.http.HttpServletResponse response)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The addCSRFToken() method is specifically designed to add CSRF protection tokens to links, which is the primary defense against cross-site request forgery attacks. The other methods serve different purposes: encryption, secure communication verification, and content type setting.

Multiple choice technology security
  1. It checks if the http request is made on an SSL channel

  2. It checks if the http method is a POST

  3. Both of the above

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The isSecureRequest method checks both SSL channel (HTTPS) and POST method. This dual check is important because sensitive data should be transmitted over SSL and state-changing operations should use POST, not GET.

Multiple choice technology security
  1. Log Message which gets logged in the log file and not safe to display to users

  2. User Message which is safe to display to users

  3. Both of the above

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

EnterpriseSecurityException contains two types of messages - a log message for developers/sysadmins that may contain sensitive details, and a user message that is safe for end users. This separation prevents information leakage.

Multiple choice technology security
  1. LoginException

  2. EnterpriseSecurityException

  3. SecurityException

  4. IntrusionException

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The login() method handles user authentication and can fail for various reasons (invalid credentials, locked account, etc.). When authentication fails, it throws a SecurityException, which is the appropriate exception type for security-related failures in the API hierarchy.

Multiple choice technology security
  1. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)

  2. void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)

  3. boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)

  4. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The correct method signature uses HttpServletResponse as the parameter since caching headers are set on the response object. The method is void because it performs an action (setting headers) rather than returning a value. Option B incorrectly uses HttpServletRequest, and options C and D have incorrect return types or exception declarations.

Multiple choice technology security
  1. encryptHiddenField(java.lang.String value)

  2. addCSRFToken(final java.lang.String href)

  3. verifySecureComm(javax.servlet.http.HttpServletRequest request)

  4. setSafeContentType(javax.servlet.http.HttpServletResponse response)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Cross Site Request Forgery (CSRF) prevention requires adding unpredictable tokens to requests that the server can verify. The addCSRFToken method is specifically designed for this purpose. Option A (encryption) and C (secure communication verification) address different security concerns, while D (content type) is about XSS prevention.

Multiple choice technology security
  1. It checks if the http request is made on an SSL channel

  2. It checks if the http method is a POST

  3. Both of the above

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The isSecureRequest method performs two critical security checks: verifying SSL usage (HTTPS) and ensuring the HTTP method is POST. POST over HTTPS provides confidentiality and is the standard for secure form submissions. Options A and B are each partially correct but incomplete.

Multiple choice technology security
  1. Log Message which gets logged in the log file and not safe to display to users

  2. User Message which is safe to display to users

  3. Both of the above

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

EnterpriseSecurityException contains two types of messages: a log message for developers/system administrators and a user message safe for display. This separation prevents exposing sensitive technical details to end users while maintaining audit trails. Options A and B are each partially correct.

Multiple choice technology security
  1. LoginException

  2. EnterpriseSecurityException

  3. SecurityException

  4. IntrusionException

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The login method throws SecurityException when authentication fails or security violations occur during the login process. This is a standard exception type for security-related failures in Java security APIs, providing a clear indication of security-related issues.

Multiple choice technology security
  1. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)

  2. void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)

  3. boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)

  4. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Cache control headers must be set on the HttpServletResponse object, not the HttpServletRequest. The method returns void as it performs an action (setting headers) rather than returning a value. ServletException is not relevant to header operations, making option A the correct signature.

Multiple choice technology security
  1. encryptHiddenField(java.lang.String value)

  2. addCSRFToken(final java.lang.String href)

  3. verifySecureComm(javax.servlet.http.HttpServletRequest request)

  4. setSafeContentType(javax.servlet.http.HttpServletResponse response)

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Preventing Cross Site Request Forgery requires associating requests with a unique, unpredictable, and user-specific token. The addCSRFToken method appends this token to URLs, verifying that the request originated from the authenticated user rather than an external site.

Multiple choice technology security
  1. It checks if the http request is made on an SSL channel

  2. It checks if the http method is a POST

  3. Both of the above

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The isSecureRequest method performs comprehensive security validation by checking both if the request uses HTTPS (SSL/TLS encrypted channel) and if it's a POST method. This dual verification ensures sensitive operations only proceed over secure connections with appropriate HTTP methods.

Multiple choice technology security
  1. Log Message which gets logged in the log file and not safe to display to users

  2. User Message which is safe to display to users

  3. Both of the above

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

EnterpriseSecurityException maintains two separate messages: a log message containing technical details for developers (written to log files, not shown to users) and a user message with sanitized, safe information appropriate for display to end users without exposing sensitive system details.