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 web technology
  1. HttpSession.setMinInactiveInterval(10);

  2. HttpSession.setMinInactiveInterval(10 * 60);

  3. HttpSession.setMaxInactiveInterval(10 * 60);

  4. HttpSession.setMaxInactiveInterval(10);

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

The setMaxInactiveInterval method accepts seconds as the parameter, not minutes. To set 10 minutes, you need to convert to seconds (10 * 60 = 600). Options A and B use setMinInactiveInterval which doesn't exist. Option D only sets 10 seconds, not 10 minutes.

Multiple choice technology web technology
  1. HttpServletRequest.getWriter();

  2. HttpServlerResponse.getCharacterWriter();

  3. HttpServetRequest.getOutputStream()

  4. HttpServletResonse.getWriter();

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

HttpServletResponse.getWriter() returns a PrintWriter object that can send character data (text) to the client. Option A is HttpServletRequest (request, not response). Option B has a typo (HttpServlerResponse) and getCharacterWriter doesn't exist. Option C is request (not response) and returns OutputStream for binary data.

Multiple choice technology web technology
  1. getAttributeNames()

  2. getAllAttributes()

  3. It is not possible to retrieve all the attributes in one call.

  4. getAttributes()

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

ServletContext.getAttributeNames() returns an Enumeration of all attribute names stored in the servlet context. Options B and D (getAllAttributes, getAttributes) are not valid methods. Option C is incorrect - you CAN retrieve all attribute names in one call.

Multiple choice technology web technology
  1. An IllegalStateException exception will be thrown because of the presence of

  2. A second call to setAttribute() with the same attribute name will just replace the

  3. The behavior is not defined in the Servlet Specification.

  4. None of the above.

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

To answer this question, the user needs to know about the HttpSession and its setAttribute() method.

Option A: This option is incorrect. IllegalStateException is thrown when we try to set an attribute on an already invalidated session, not when we set an attribute with the same name.

Option B: This option is correct. A second call to setAttribute() with the same attribute name will just replace the previous value associated with the attribute name with the new value.

Option C: This option is incorrect. The Servlet Specification does define the behavior of HttpSession.setAttribute() method when it is called the second time with the same attribute name.

Option D: This option is incorrect as option B is the correct answer.

Therefore, the correct answer is:

The Answer is: B. A second call to setAttribute() with the same attribute name will just replace the previous value associated with the attribute name with the new value.

Multiple choice technology platforms and products
  1. Client

  2. Bindings

  3. No default. The transport has to be defined explicitly

  4. None of the above

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

When defining a JNDI connection factory for IBM WebSphere MQ, the default transport type is 'Bindings' mode. This provides direct in-memory communication when client and queue manager are on the same machine. 'Client' transport (TCP/IP) must be explicitly specified for remote connections.

Multiple choice technology web technology
  1. init()

  2. service()

  3. getServletContext()

  4. getServletConfig()

  5. getServletInfo()

Reveal answer Fill a bubble to check yourself
D,E Correct answer
Explanation

The Servlet interface has 5 methods: lifecycle methods (init, service, destroy) and ancillary methods (getServletConfig, getServletInfo). The question asks for ancillary methods - those NOT part of the core lifecycle. getServletConfig() returns the servlet's configuration object, and getServletInfo() returns descriptive information about the servlet. These are considered ancillary/support methods. Options A and B are lifecycle methods. Option C (getServletContext) returns the context but is NOT a method of Servlet interface - it's a method of ServletConfig interface (accessed via getServletConfig().getServletContext()).

Multiple choice technology web technology
  1. The service() method is the heart of the servlet.

  2. Each request message from a client results in a single call to the servlet's service() method

  3. The service() method reads the request and produces the response message from its parameters

  4. The service() method is called to allow your servlet to clean up any resources before the servlet is unloaded.

  5. The InputStream from the client can be obtained via the getInputStream() method

Reveal answer Fill a bubble to check yourself
A,B,C,E Correct answer
Explanation

The service() method is indeed the core of a servlet - every client request triggers a single call to service(), which reads the HttpServletRequest and produces the HttpServletResponse. The InputStream from the client can be obtained via request.getInputStream(). Option D describes the destroy() method, not service().

Multiple choice technology web technology
  1. Servlets are used to process the client request

  2. Servlets enables rapid development of mission-critical application that are versatile, reusable and portable across middleware while protecting IT investment

  3. A Servlet can handle multiple request concurrently and be used to develop high performance system

  4. A Servlet can be used to load balance among serveral servers, as Servlet can easily forward request

  5. With the help of servlet we can achieve Clustering

Reveal answer Fill a bubble to check yourself
A,C,D Correct answer
Explanation

Servlets process client requests (A), handle multiple concurrent requests for high performance (C), and can forward requests to enable load balancing (D). Option B is incorrect because it describes EJBs, not servlets. Option E is incorrect - clustering is achieved at the application server level, not by servlets themselves.

Multiple choice technology web technology
  1. Run on Java enabled web browser

  2. Serverside Applet

  3. Platform independent

  4. Multithread processing

  5. Session information is maintainable with servlets

Reveal answer Fill a bubble to check yourself
B,C,D,E Correct answer
Explanation

Servlets are server-side components that run in a web container, NOT in a browser (A is false). They are platform-independent Java programs (C), support multithreaded request processing (D), and can maintain session information via HttpSession (E). The term 'Serverside Applet' is accurate (B).

Multiple choice technology web technology
  1. j_login

  2. j_get_user

  3. j_login_check

  4. j_get_security

  5. j_security_check

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

In Java EE form-based authentication, the login form must POST to j_security_check. This is a built-in servlet container endpoint that receives j_username and j_username parameters, authenticates the user against the realm, and redirects to the protected resource or error page. The other options (j_login, j_get_user, j_login_check, j_get_security) are not standard container-managed authentication endpoints.

Multiple choice technology web technology
  1. <realm-name>

  2. <auth-method>

  3. <security-role>

  4. <transport-guarantee>

  5. <web-resource-collection>

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

The element is required in a because it defines which resources (URL patterns) are being protected. The other elements ( goes in , goes in , is a separate top-level element, goes in ) serve different purposes or are in different sections of the deployment descriptor.

Multiple choice technology web technology
  1. An error occurs during page translation

  2. Translation is successful, but nothing is included in the response.

  3. Both "10 x 5 = 50" and "2 * 3 = 6" are included in the JSP response

  4. The text "10 x 5 = 50" is included in the JSP response, but "2 * 3 = 6" is NOT

  5. The text "2 * 3 = 6" is included in the JSP response, but "10 x 5 = 50" is NOT

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

When is false, both scripting expressions (<%= ... %>) and EL expressions (${ ... }) are allowed. Therefore, the JSP will successfully translate and execute both '10 x 5 = 50' (using EL) and '2 * 3 = 6' (using scripting expression). Setting it to true would disable scripting elements but not EL.