Computer Knowledge

Java Enterprise and Web Technologies

2,279 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. <jsp:declareBean id = "harry" class = "EmployeeBean" scope = "request" />

  2. <jsp:createBean id = "harry" class = "EmployeeBean" />

  3. <jsp:useBean id = "harry" class = "EmployeeBean" scope = "request" />

  4. <jsp:useBean id = "harry" class = "EmployeeBean" />

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

The jsp:useBean tag with scope='request' exactly matches the Java code logic: it checks if 'harry' exists in request scope, and if null, creates a new EmployeeBean and stores it. Option A has wrong tag name, B has wrong tag name, and D omits scope specification which would default to page scope.

Multiple choice technology web technology
  1. ${request.getAttribute()}
  2. ${request.attribute}
  3. ${pageContext.request.getAttribute()}
  4. ${pageContext.request.attribute}
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In EL (Expression Language), request attributes are accessed via ${pageContext.request.attributeName}. The pageContext implicit object provides access to request attributes. Options A and C incorrectly use getAttribute() syntax, and B accesses a non-existent 'attribute' property directly on request.

Multiple choice technology web technology
  1. The Servlet will output 'javabeat null' in the Server Console.

  2. The Servlet will fail to load as the init param property 'no-name' is not mentioned in the deployment descriptor

  3. A NullPointerException will be raised as calling getServletConfig() in the init() method will return a null reference.

  4. The Servlet will output 'javabeat ' in the Server Console.

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

The getServletConfig().getInitParameter('no-name') call will return null when the parameter is not defined in web.xml, but this does not cause an exception - the servlet will load successfully and output 'javabeat null'. The init() method can safely call getServletConfig() and getInitParameter() returns null for missing parameters rather than throwing NullPointerException.

Multiple choice technology programming languages
  1. Web services

  2. Enterprise JavaBeans

  3. Java Servlets

  4. All the above

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

Java enables portable server-side applications across multiple technologies: Web services (SOAP/REST), Enterprise JavaBeans (EJB for business logic), and Java Servlets (web request handling). All three are core server-side Java technologies, making 'All the above' the correct answer.

Multiple choice technology enterprise content management
  1. http://<server_hostname>/icmrm/snoop

  2. http://<server_hostname>:port/icmrm/snoop

  3. https://<server_hostname>:SSL_port/icmrm/snoop

  4. All of above

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

The Snoop Servlet can be accessed using HTTP or HTTPS, with or without explicit port numbers depending on the server configuration, making all of the listed URLs valid test paths.

Multiple choice technology web technology
  1. response.getWriter()

  2. response.getOutputStream()

  3. response.getOutputWriter()

  4. response.getWriter(Writer.OUTPUT_BINARY)

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

ServletResponse.getOutputStream() returns a ServletOutputStream for writing binary data. The getWriter() method returns a PrintWriter, which is for character/text data only. You cannot call both getOutputStream() and getWriter() on the same response.

Multiple choice technology web technology
  1. request.getCookies()

  2. request.getAttributes()

  3. request.getSession (). GetAttributes()

  4. request.getSession ().getCookies()

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

HttpServletRequest.getCookies() returns an array of Cookie objects sent with the request. The other options are incorrect: getAttributes() is for request attributes, and getSession() returns the HttpSession object which has different methods.

Multiple choice technology web technology
  1. The servlet's init method returns a non-zero status

  2. The servlet's init method throws a Servlet Exception

  3. The servlet's init method sets the Servlet Response's content type to null.

  4. The servlet's init method does NOT return within a time period defined by the servlet container

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

A servlet cannot handle requests if its init() method throws ServletException (makes servlet unavailable) or doesn't return within the container-defined timeout (considered failed initialization). A non-zero return status doesn't apply (init is void), and setting content type to null doesn't prevent initialization.

Multiple choice technology web technology
  1. id

  2. type

  3. name

  4. class

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

To instantiate a JavaBean with jsp:useBean, you must specify 'id' (the variable name to reference the bean) and 'class' (the fully qualified class name to instantiate). The 'type' attribute is optional (for casting), and 'name' is not a standard attribute.

Multiple choice technology web technology
  1. a base-64 encoded user name and password

  2. a form that POSTs to the j_security_check URL

  3. an applet that requests the user name and password from the user

  4. a hidden field that supplies the login-constraint used by the application

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

Form-based authentication requires the login page to contain a form that POSTs to j_security_check with j_username and j_password fields. The servlet container handles the authentication processing at this URL.

Multiple choice technology web technology
  1. A Servlet is a Server-side entity that will rest only on the Server.

  2. The life-cycle management of Servlets is done by the programmer.

  3. Java Servlet Technology provides support for handling XML requests through a special Servlet called XmlServlet.

  4. A Servlet instance is created by the client during the first request to the Servlet Container.

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

A Servlet is indeed a server-side component that resides and executes on the server, managed by the Servlet Container. Options B, C, and D are incorrect: Servlet lifecycle is managed by the container (not programmer), there's no special XmlServlet class, and instances are created by the container (not clients).

Multiple choice technology web technology
  1. session-timeout

  2. session-min-time

  3. session-inactive-time

  4. session-interval-time

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

The session-timeout tag is used within the element in web.xml to specify session timeout in minutes. The other options (session-min-time, session-inactive-time, session-interval-time) are not valid XML tags for session configuration.

Multiple choice technology web technology
  1. <session-listener>

  2. <listener>

  3. <http-session-listener>

  4. A listener for HttpSession cannot be specified statically inside a Deployment Descriptor, instead it can be programmatically mentioned.

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

Listeners are configured in web.xml using the tag with a subelement specifying the fully qualified class name. Options A and C are not valid tags. Option D is incorrect - listeners CAN be specified statically in deployment descriptors.

Multiple choice technology web technology
  1. ServletContextListener

  2. ApplicationListener

  3. ApplicationContextListener

  4. None of the above.

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

ServletContextListener is specifically designed to receive notifications when the web application is initialized (contextInitialized method) and destroyed. The other options (ApplicationListener, ApplicationContextListener) are not standard Servlet API listeners.