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. Another JSP

  2. Plain text file

  3. Servlet

  4. CGI Program

  5. All of the above

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

The action can include output from various resources including other JSP pages, plain text files, servlets, and even CGI programs through the servlet container's resource handling mechanisms. This makes it a flexible tool for composing dynamic content from multiple sources.

Multiple choice technology web technology
  1. Using the <jsp:readParam/> action

  2. Using the <jsp:getParam/> action

  3. Use the request.getParameter() method

  4. Use the response.getParameter() method

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

When passes parameters to the included page, those parameters become part of the HTTP request. The included page accesses them using the standard request.getParameter() method, just like any other request parameter, because jsp:include uses a request-time inclusion mechanism.

Multiple choice technology programming languages
  1. page

  2. pageContext

  3. context

  4. object

  5. jspPave

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

pageContext is the implicit JSP object that provides access to all other implicit objects and page-related information. The page object refers to the current servlet instance, context is not a valid implicit object name (it's application), and object/jspPave don't exist.

Multiple choice technology programming languages
  1. <jsp:getColor bean="fruit"/>

  2. <jsp:getProperty id="fruit" property="color"/>

  3. <jsp:getProperty bean="fruit" property="color"/>

  4. <jsp:getProperty name="fruit" property="color"/>

  5. <jsp:getProperty class="Fruit" property="color"/>

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

The standard JSP action to retrieve a property from a JavaBean is . It requires the 'name' attribute (matching the 'id' in useBean) and the 'property' attribute. Option 539806 correctly uses 'name' instead of 'id' or 'bean'.

Multiple choice technology programming languages
  1. This is incorrect syntax of <jsp:setProperty/> and will generate a compilation error. Either value or param must be defined.

  2. All the properties of the fruit bean are initialized to a value of null.

  3. All the properties of the fruit bean are assigned the values of input parameters of the JSP page that have the same name.

  4. All the properties of the fruit bean are initialized to a value of *.

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

When property="*" is used in , it automatically matches request parameter names to bean property names and sets all matching properties. This is a shorthand for bulk property setting from HTTP parameters.

Multiple choice technology programming languages
  1. True

  2. False

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

When isThreadSafe="false" is set in the page directive, the JSP container generates a servlet implementing SingleThreadModel. This interface ensures thread safety by serializing requests through the servlet, though it's deprecated in modern servlet specs.

Multiple choice technology programming languages
  1. <jsp:usebean id="fruit scope ="page"/>

  2. <jsp:usebean id="fruit type ="String"/>

  3. <jsp:usebean id="fruit type ="String" beanName="Fruit"/>

  4. <jsp:usebean id="fruit class="Fruit" beanName="Fruit"/>

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

Valid syntax requires id attribute and either type or class (or type with beanName). Option A is missing equals signs. Option D incorrectly combines class with beanName. Options B and C show valid attribute combinations.

Multiple choice technology programming languages
  1. \doc-root\dd.xml

  2. \doc-root\web.xml

  3. \doc-root\WEB-INF\web.xml

  4. \doc-root\WEB_INF\dd.xml

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

To solve this question, the user needs to know the naming convention and location of the deployment descriptor for a web application.

The deployment descriptor is an XML file that contains information about the web application, such as the servlets, filters, and other components that make up the application. It is used by the web server or servlet container to configure the application at runtime.

Now, let's go through each option and explain why it is right or wrong:

A. \doc-root\dd.xml: This option is incorrect because the deployment descriptor must be located in the WEB-INF directory of the web application. Therefore, option A is not a valid location for the deployment descriptor.

B. \doc-root\web.xml: This option is incorrect because the deployment descriptor must be located in the WEB-INF directory of the web application. Therefore, option B is not a valid location for the deployment descriptor.

C. \doc-root\WEB-INF\web.xml: This option is correct. This is the correct location and naming convention for the deployment descriptor of a web application. The WEB-INF directory is a special directory that is not directly accessible from the web, so it is a secure location to store configuration files.

D. \doc-root\WEB_INF\dd.xml: This option is incorrect because the deployment descriptor must be named "web.xml" and it must be located in the WEB-INF directory of the web application. Therefore, option D is not a valid location or naming convention for the deployment descriptor.

The Answer is: C

Multiple choice technology programming languages
  1. servlet-config

  2. init-param

  3. load-on-startup

  4. filter

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

The init-param element within servlet defines initialization parameters that are accessible via the ServletConfig object. These parameters are specified as name-value pairs and retrieved using getInitParameter() method in the servlet.

Multiple choice technology programming languages
  1. error-page

  2. servlet

  3. exception

  4. error-handling

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

The exception-type element is used within the error-page element to specify which Java exception should trigger the error handling. When that exception is thrown, the container redirects to the specified location. The servlet element (option B) contains servlet configuration, not error handling. Elements named exception or error-handling (options C, D) are not standard deployment descriptor elements.

Multiple choice technology programming languages
  1. <exception> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </exception>

  2. <error-page> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </error-page>

  3. <error-page> <exception> mypackage.MyException </exception-type> <location> /error.jsp </location> </error-page>

  4. <error-page> <exception-type> mypackage.MyException</exception-type> </error-page>

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

The error-page element in web.xml contains either an exception-type subelement (for Java exceptions) OR an error-code subelement (for HTTP status codes), plus a required location subelement pointing to the error page. Option A uses the non-existent exception element. Option C incorrectly uses exception as element name. Option D is missing the required location element. Only option B has the correct structure.

Multiple choice technology programming languages
  1. web-app

  2. welcome-file

  3. servlet

  4. file-list

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

The welcome-file-list element is a direct child of the web-app root element in web.xml. It defines the list of files the server should look for when a client requests a directory URL. Option B (welcome-file) is a subelement within welcome-file-list, not its parent. Options C and D (servlet, file-list) are not valid parents for welcome-file-list.