JSTL/JSTL MCQ OUESTIONS AND ANSWERS Sample Test,Sample questions

Question:
 How can you access the value of a session attribute named “user” using JSTL?

1. ${session.user}

2.${request.user}

3. ${pageContext.user}

4.${application.user}

Posted Date:-2024-01-05 12:44:20


Question:
 How can you set the content type of a JSP page to JSON?

1.<%@ page contentType=”application/json” %>

2. <%@ page type=”application/json” %>

3. <%@ contentType=”application/json” %>

4.<%@ type=”application/json” %>

Posted Date:-2024-01-05 12:27:01


Question:
 How can you set the content type of a JSP page to JSON?

1.<%@ page contentType=”application/json” %>

2. <%@ page type=”application/json” %>

3. <%@ contentType=”application/json” %>

4.<%@ type=”application/json” %>

Posted Date:-2024-01-05 12:27:01


Question:
 How do you access a session attribute named “user” in JSP?

1. <%= session.getAttribute(“user”) %>

2. <%= request.getSessionAttribute(“user”) %>

3. <%= page.getAttribute(“user”) %>

4.<%= application.getAttribute(“user”) %>

Posted Date:-2024-01-05 12:21:07


Question:
 How do you iterate over the elements of a collection using JSTL?

1.<c:forEach>

2. <c:for>

3.<c:repeat>

4.<c:loop>

Posted Date:-2024-01-05 12:40:57


Question:
 How do you iterate over the elements of a collection using JSTL?

1.<c:forEach>

2. <c:for>

3.<c:repeat>

4.<c:loop>

Posted Date:-2024-01-05 12:40:58


Question:
 In JSP, how can you include a JavaBean object in the page scope?

1. <jsp:useBean>

2.<jsp:setBean>

3. <jsp:includeBean>

4.<jsp:object>

Posted Date:-2024-01-05 12:18:48


Question:
 In JSP, what is the purpose of the <%@ page import=”java.util.*” %> directive?

1. To import all classes from the java.util package

2. To import a specific class from the java.util package

3.To declare a custom Java class

4.To declare a custom JSP tag

Posted Date:-2024-01-05 12:38:40


Question:
 What does JSP stand for?

1. Java Server Page

2.JavaScript Page

3.Java Scripted Page

4. Java Standard Page

Posted Date:-2024-01-05 09:31:50


Question:
 What is the default scope of a JSP page’s attribute if no scope is specified explicitly?

1.Page

2. Request

3.Session

4.Application

Posted Date:-2024-01-05 11:50:04


Question:
 What is the purpose of the out object in JSP?

1.To handle exceptions

2.To set session attributes

3.To write output to the response

4.To manage database connections

Posted Date:-2024-01-05 12:33:44


Question:
 Which JSP directive is used to include content from another resource at translation time?

1. <%@ include %>

2.<%! include %>

3.<%# include %>

4.<%& include %>

Posted Date:-2024-01-05 09:41:04


Question:
 Which JSP element is used to display the result of Java expression evaluation in the output?

1.<%! %>

2. <%= %>

3. <%# %>

4.<%? %>

Posted Date:-2024-01-05 09:52:21


Question:
 Which JSTL tag is used to format numbers and dates?

1. <c:format>

2.<c:convert>

3.<c:parse>

4.<c:output>

Posted Date:-2024-01-05 12:46:07


Question:
How do you include a JSP file based on a condition using the <c:choose> tag?

1.<c:choose><c:when test=”${condition}”><jsp:include page=”file.jsp”/></c:when></c:choose>

2. <c:if test=”${condition}”><jsp:include page=”file.jsp”/></c:if>

3.<c:when test=”${condition}”><jsp:include page=”file.jsp”/></c:when>

4. <c:include test=”${condition}”><jsp:include page=”file.jsp”/></c:include>

Posted Date:-2024-01-05 12:34:48


Question:
How do you include another JSP page within the current JSP page?

1. <jsp:include>

2.<jsp:page>

3.<jsp:import>

4.<jsp:component>

Posted Date:-2024-01-05 09:53:36


Question:
How do you include the contents of a JSP fragment into another JSP page using JSTL?

1.<c:fragment>

2. <c:import>

3. <c:include>

4. <c:insert>

Posted Date:-2024-01-05 12:47:07


Question:
How do you include the contents of an external file in a JSP page without using a JSP tag?

1. <jsp:include file=”external.jsp”/>

2.<%@ include file=”external.jsp” %>

3. <jsp:import file=”external.jsp”/>

4. <jsp:content file=”external.jsp”/>

Posted Date:-2024-01-05 12:31:40


Question:
In JSP, how can you retrieve a parameter from the request object?

1. request.getParameter()

2.request.getParameters()

3. request.getParameterValues()

4.request.getParameterList()

Posted Date:-2024-01-05 12:16:32


Question:
In JSP, how do you define a session attribute named “username” with the value “John”?

1.<session:username value=”John”/>

2. <session:setAttribute name=”username” value=”John”/>

3.<session:setProperty name=”username” value=”John”/>

4.<session:set name=”username” value=”John”/>

Posted Date:-2024-01-05 11:53:41


Question:
In JSP, how do you import a Java class for use in a JSP page?

1.<import>

2.<jsp:import>

3.<%@ page import>

4.<jsp:useBean>

Posted Date:-2024-01-05 09:49:34


Question:
In JSP, how do you redirect the user to another page or URL?

1. response.redirect(“newPage.jsp”)

2. request.forward(“newPage.jsp”)

3.response.sendRedirect(“newPage.jsp”)

4. request.send(“newPage.jsp”)

Posted Date:-2024-01-05 12:35:39


Question:
In JSP, what is the purpose of the <%@ page errorPage=”error.jsp” %> directive?

1.To specify a custom error page

2.To define an error message

3.To include an error message

4.To handle exceptions

Posted Date:-2024-01-05 12:30:53


Question:
In JSP, what is the purpose of the <%– … –%> tag?

1.To define a comment

2.To include external JavaScript

3.To declare variables

4.To print output

Posted Date:-2024-01-05 09:38:56


Question:
In JSP, what is the purpose of the application scope?

1.To store data that is specific to a single user’s session

2.To store data that is shared among all users of the web application

3.To store data that is specific to a single JSP page

4.To store data that is specific to a single HTTP request

Posted Date:-2024-01-05 12:43:27


Question:
In JSP, which object is used to store information about a user’s session?

1.request

2.session

3.pageContext

4.application

Posted Date:-2024-01-05 12:32:41


Question:
JSTL May be use the following TLD file 

1.c.tld

2.x.tld

3.fmt.tld

4.All of the above.

Posted Date:-2024-01-05 17:10:30


Question:
put JSTL lib on the web applicant// 

1. WEB-INF/lib

2.lib

3.common/lib on container home path

4.None of the above

Posted Date:-2024-01-05 17:12:10


Question:
the JSTL implementation,There are two JAR files

1.jstl.jar,standard.jar

2.c.ltd,x.tld

3.jstl.ltd,standard.tld

4.None of these

Posted Date:-2024-01-05 17:00:41


Question:
The JSTL is often referred to as a single tag library when in fact it’s a collection of four tag libraries

1.i18n

2.Core

3.JPA

4.None of these

Posted Date:-2024-01-05 17:12:50


Question:
To be able to use the JSTL, you must have the following:

1.At least a Servlet 2.3– and JSP 1.2–compliant container

2.Scriplets

3.An implementation of the JSTL specification

4.All of the above.

Posted Date:-2024-01-05 17:00:03


Question:
What is the correct syntax for defining a custom JSP tag in a JSP file?

1.<@tag:mytag>

2.<jsp:custom-tag>

3.<custom:mytag>

4.<%@taglib uri=”…” prefix=”custom” %>

Posted Date:-2024-01-05 12:22:18


Question:
What is the correct syntax for defining a custom JSP tag in a JSP file?

1.<@tag:mytag>

2.<jsp:custom-tag>

3.<custom:mytag>

4.<%@taglib uri=”…” prefix=”custom” %>

Posted Date:-2024-01-05 12:22:18


Question:
What is the correct syntax for including a JSP file named “header.jsp” in another JSP file?

1.<jsp:include file=”header.jsp”/>

2.<jsp:include page=”header.jsp”/>

3.<jsp:include src=”header.jsp”/>

4.<jsp:include source=”header.jsp”/>

Posted Date:-2024-01-05 12:14:21


Question:
What is the primary purpose of the <jsp:forward> tag in JSP?

1.To redirect the user to another page or URL

2.To include the contents of another JSP page

3.To handle exceptions in JSP

4.To send an HTTP request to another servlet

Posted Date:-2024-01-05 12:48:20


Question:
What is the purpose of the JSP Expression Language (EL)?

1. To define custom JSP tags

2.To write Java code in JSP pages

3.To evaluate and display Java expressions in JSP

4.To handle exceptions in JSP

Posted Date:-2024-01-05 12:40:01


Question:
What is the purpose of the JSTL <c:if> tag?

1.To define custom JSP tags

2.To conditionally display content in a JSP page

3.To create a loop in a JSP page

4.To include external resources in a JSP page

Posted Date:-2024-01-05 12:45:17


Question:
Which file extension is used for JSP files?

1..java

2.jspf

3.jsp

4.jsf

Posted Date:-2024-01-05 09:33:13


Question:
Which JSP directive is used to specify the character encoding for a JSP page?

1.<%@ page contentType=”text/html; charset=UTF-8? %>

2.<%@ charset=”UTF-8? %>

3. <%@ encoding=”UTF-8? %>

4.<%@ charset=UTF-8 %>

Posted Date:-2024-01-05 12:15:27


Question:
Which JSP tag is used for conditional processing in JSP pages?

1.<c:choose>

2.<c:if>

3. <c:when>

4.<c:case>

Posted Date:-2024-01-05 12:20:16


Question:
Which JSP tag is used for including external resources like CSS or JavaScript files?

1. <jsp:resource>

2. <jsp:import>

3.<link>

4.<jsp:external-resource>

Posted Date:-2024-01-05 12:23:36


Question:
Which JSP tag is used to create reusable content that can be included in other JSP pages?

1.<jsp:include>

2.<jsp:directive.include>

3.<jsp:taglib>

4.<jsp:useBean>

Posted Date:-2024-01-05 11:52:26


Question:
Which JSP tag is used to define a function in JSTL?

1.<c:function>

2.<c:defineFunction>

3.<c:fn>

4. <c:method>

Posted Date:-2024-01-05 12:41:47


Question:
Which JSP tag is used to handle exceptions in JSP pages?

1.<%@ page errorPage=”errorPage.jsp” %>

2.<c:try>

3.<c:exception>

4.<c:catch-exception>

Posted Date:-2024-01-05 12:28:25


Question:
Which JSP tag is used to iterate over a collection in JSP?

1. <c:for>

2.<c:loop>

3. <c:forEach>

4. <c:iterate>

Posted Date:-2024-01-05 12:17:29


Question:
Which JSTL tag is used to set a variable in JSP?

1. <c:set>

2. <c:var>

3.<c:variable>

4. <c:define>

Posted Date:-2024-01-05 12:36:38


Question:
Which method is called when a JSP page is first requested by a client?

1. init()

2.service()

3.doGet()

4. jspInit()

Posted Date:-2024-01-05 09:55:25


Question:
which one is the correct include core jstl library

1.&lt%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %&gt

2.&lt%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt

3. &lt%@ taglib uri="http://java.sun.com/jsf/core" prefix="c" %&gt

4.All of these

Posted Date:-2024-01-05 17:18:22


Question:
which one is the correct include core jstl library

1.&lt%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %&gt

2.&lt%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt

3. &lt%@ taglib uri="http://java.sun.com/jsf/core" prefix="c" %&gt

4.All of these

Posted Date:-2024-01-05 17:18:22


Question:
Which tag is used to define a JSP declaration?

1.<%@ %>

2.<%! %>

3. <%= %>

4. <%# %>

Posted Date:-2024-01-05 09:36:29


More MCQS

  1. JSTL MCQ OUESTIONS AND ANSWERS
  2. JNDI MCQ QUESTIONS AND ANSWER
  3. JNDI MCQ QUESTIONS AND ANSWER
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!