0

JSP and Servlet Quiz

Description: JSP and Servlet Quiz
Number of Questions: 11
Created by:
Tags: java jsp
Attempted 0/11 Correct 0 Score 0

In JSP, how can you know what HTTP method (GET or POST) is used by client request ?

  1. by using request.getMethod()

  2. by using request.setMethod()

  3. impossible to know

  4. none of these


Correct Option: A
Explanation:

To determine the HTTP method (GET or POST) used by a client request in JSP, you can use the request.getMethod() method.

The correct answer is:

The Answer is: A. by using request.getMethod()

Explanation:

A) by using request.getMethod(): This option is correct. The request.getMethod() method is used to retrieve the HTTP method used by the client request. It returns a string representing the HTTP method, such as "GET" or "POST".

B) by using request.setMethod(): This option is incorrect. The request.setMethod() method does not exist in JSP. There is no built-in method to set the HTTP method of a request.

C) impossible to know: This option is incorrect. It is possible to know the HTTP method used by the client request by using the request.getMethod() method.

D) none of these: This option is incorrect. The correct answer is option A, as explained above.

Therefore, the correct answer is:

The Answer is: A. by using request.getMethod()

  1. A loop can begin in one Scriptlet and end in another

  2. Statements in Scriptlets should follow Java Syntax

  3. Semicolon is needed at the end of each statement in a Scriptlet

  4. All the above


Correct Option: D
  1. Stateless session beans doesn’t preserve any state across method calls

  2. Stateful session beans can be accesses by multiple users at the same time


Correct Option: A

What is sent to the user via HTTP, invoked using the HTTP protocol on the user's computer, and run on the user's computer as an application?

  1. A Java application

  2. A Java applet

  3. A Java servlet

  4. None of the above is correct.


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) A Java application - This option is incorrect because a Java application is typically executed on a server and not sent to the user's computer via HTTP.

Option B) A Java applet - This option is correct because a Java applet is sent to the user's computer via HTTP, invoked using the HTTP protocol, and run on the user's computer as an application.

Option C) A Java servlet - This option is incorrect because a Java servlet is executed on a server and not sent to the user's computer via HTTP.

Option D) None of the above is correct - This option is incorrect because option B, a Java applet, is the correct answer.

The correct answer is B) A Java applet. This option is correct because it is sent to the user via HTTP, invoked using the HTTP protocol on the user's computer, and run on the user's computer as an application.

A JSP is transformed into a(n):

  1. Java applet.

  2. Java servlet.

  3. Either 1 or 2 above.

  4. Neither 1 nor 2 above.


Correct Option: B

AI Explanation

To answer this question, you need to understand the role of JSP (JavaServer Pages) and its transformation process.

JSP is a technology used to create dynamic web pages. It allows developers to embed Java code within HTML pages, which is then executed on the server side. JSP pages are transformed into Java servlets during the compilation process.

Option A) Java applet - This option is incorrect because JSP pages are not transformed into Java applets. Java applets are client-side programs that run within a web browser and are embedded within HTML pages.

Option B) Java servlet - This option is correct. JSP pages are transformed into Java servlets. Servlets are server-side programs that run on a web server and generate dynamic content to be sent back to the client.

Option C) Either 1 or 2 above - This option is incorrect because JSP pages are specifically transformed into Java servlets and not Java applets.

Option D) Neither 1 nor 2 above - This option is incorrect. JSP pages are transformed into Java servlets, so option D is not the correct answer.

The correct answer is B) Java servlet. This option is correct because JSP pages are transformed into Java servlets during the compilation process.

  1. VBScript only

  2. Jscript only

  3. Java only

  4. All of the above are supported


Correct Option: C

What servlet processor was developed by Apache Foundation and Sun?

  1. Apache Tomcat

  2. Apache Web server

  3. Sun servlet processor

  4. None of the above is correct.


Correct Option: A

AI Explanation

To answer this question, you need to understand the concept of servlet processors and the technologies developed by Apache Foundation and Sun.

Option A) Apache Tomcat - This option is correct. Apache Tomcat is a servlet container developed by the Apache Foundation in collaboration with Sun Microsystems. It is an open-source software implementation of the Java Servlet, JavaServer Pages (JSP), and WebSocket technologies.

Option B) Apache Web server - This option is incorrect. Apache Web server, also known as Apache HTTP Server, is a web server software developed by the Apache Software Foundation. While it can be used to serve static web pages, it is not specifically designed as a servlet processor.

Option C) Sun servlet processor - This option is incorrect. While Sun Microsystems, now Oracle Corporation, has contributed to the development of Java technologies, there is no specific servlet processor named "Sun servlet processor."

Option D) None of the above is correct - This option is incorrect. The correct answer is Apache Tomcat, which is the servlet processor developed by the Apache Foundation and Sun Microsystems.

The correct answer is A) Apache Tomcat. This option is correct because Apache Tomcat is the servlet processor developed by the Apache Foundation and Sun Microsystems.

  1. A Java application

  2. A Java applet

  3. A Java servlet

  4. None of the above is correct.


Correct Option: C

How many copies of a JSP page can be in memory at a time?

  1. One

  2. Two

  3. Three

  4. Unlimited


Correct Option: A

How does Tomcat execute a JSP?

  1. As a CGI script

  2. As an independent process

  3. By one of Tomcat's threads

  4. None of the above is correct.


Correct Option: C
- Hide questions