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
  1. Applets

  2. Web Browsers

  3. Wireless clients.

  4. All the above

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

J2EE architecture supports multiple client types. Applets can be J2EE clients (RMI/IIOP), Web Browsers access via HTTP/HTTPS, and Wireless clients (WAP, mobile) access through specialized servlets/JSP. All three are valid J2EE client types, making 'All the above' the correct answer.

Multiple choice technology
  1. True

  2. False

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

JSP allows embedding pure Java code through scriptlets (<% ... %>). You can write any valid Java code inside these scriptlet blocks. However, this is considered poor practice in modern JSP development - JSTL tags, EL expressions, and MVC patterns are preferred. The question asks about capability, not best practices.

Multiple choice technology
  1. True

  2. False

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

In J2EE web applications, all custom servlets handling HTTP requests must extend javax.servlet.http.HttpServlet. This abstract class provides HTTP-specific functionality (doGet, doPost, etc.). While you could technically implement Servlet directly, HttpServlet is the standard base for all HTTP servlets in J2EE.

Multiple choice technology
  1. True

  2. False

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

JSP translation to Servlet happens ONLY ONCE - when the JSP is first accessed. The container generates the Servlet code, compiles it, and loads it. All subsequent requests reuse the same compiled Servlet instance. Translating on every request would destroy performance. This is why JSP changes require redeployment or container restart.

Multiple choice technology
  1. Yes, but always call the default constructor.

  2. No, no need to call the default constructor.

  3. yes, always.

  4. no, always.

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

You CAN write a constructor for a Servlet, but the servlet container (not your code) calls the no-argument constructor during instantiation via reflection. If you write a parameterized constructor, it won't be used. The option 'Yes, but always call the default constructor' is misleading - the container calls it, not your code. Option A is technically correct but poorly phrased.

Multiple choice technology
  1. ServletContext gives information about Container

  2. ServletContext gives information about Request

  3. ServletContext gives information about Session

  4. none

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

ServletContext provides information about the servlet container and allows servlets to communicate with it. It gives access to container-wide configuration parameters, resources, and attributes shared across all servlets in the application. It does not provide information about individual requests or sessions - those are handled by HttpServletRequest and HttpSession respectively.

Multiple choice technology
  1. only request, response

  2. only request, response & application

  3. request, response, session & application

  4. none

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

JSP provides several implicit objects automatically available without declaration: request (HttpServletRequest), response (HttpServletResponse), session (HttpSession), and application (ServletContext). These objects handle client requests, server responses, user session management, and application-wide operations respectively. Option C correctly lists four key implicit objects.

Multiple choice technology
  1. True

  2. False

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

When a JSP page is first requested, the web container translates it into a servlet class and creates a servlet instance. This instance then handles all subsequent requests to that JSP. The servlet lifecycle (init, service, destroy) applies to the generated servlet, not directly to the JSP source code. Therefore, a servlet object is indeed created during JSP execution.

Multiple choice technology
  1. ejb-jar.xml

  2. Can be any valid xml containing Web Module name

  3. web.xml

  4. config.xml

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

The web.xml file is the standard deployment descriptor for Java web applications. It contains configuration information for servlets, filters, listeners, welcome files, and other web application components. The web container reads web.xml during deployment to understand how to initialize and run the application. Option A (ejb-jar.xml) is for EJB modules, and the file must be specifically named web.xml.

Multiple choice technology
  1. True

  2. False

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

A single servlet instance typically handles multiple concurrent requests using a multi-threaded model. The container creates one instance (or a pool) and dispatches multiple threads to the service() method simultaneously. Each thread handles one request, allowing efficient resource utilization. Developers must ensure thread-safety in servlet code since instance variables are shared across threads.

Multiple choice technology
  1. True

  2. False

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

ServletContext provides an interface for servlets to interact with their runtime environment (the servlet container). Through ServletContext, servlets can access initialization parameters, container-wide resources, and share information with other servlets. It provides methods like getInitParameter(), getAttribute(), and log() to communicate with the container and application environment.

Multiple choice technology
  1. init()

  2. service()

  3. destroy()

  4. Above All

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

The servlet lifecycle consists of three main methods: init() (called once when servlet is initialized), service() (called for each request to handle business logic), and destroy() (called once before servlet is removed from service). All three are essential lifecycle methods, so Option D (Above All) is correct as it encompasses all of them. Option C only names destroy(), which is incomplete.

Multiple choice technology
  1. 2

  2. 1

  3. not fixed

  4. 3

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

There is exactly one ServletContext object per web application. It is created by the container when the application is deployed and shared by all servlets in that application. This singleton pattern ensures all servlets access the same application-wide configuration and attributes. The context is destroyed when the application is undeployed or the container shuts down.

Multiple choice technology
  1. True

  2. False

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

Servlets use a multi-threaded model where a single servlet instance handles multiple requests concurrently. Each request runs in a separate thread, sharing the same servlet instance, which makes resource-efficient but requires thread-safe coding.