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}


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” %>


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” %>


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”) %>


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>


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>


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>


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


Question:
 What does JSP stand for?

1. Java Server Page

2.JavaScript Page

3.Java Scripted Page

4. Java Standard Page


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


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


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

1. <%@ include %>

2.<%! include %>

3.<%# include %>

4.<%& include %>


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

1.<%! %>

2. <%= %>

3. <%# %>

4.<%? %>


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

1. <c:format>

2.<c:convert>

3.<c:parse>

4.<c:output>


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>


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>


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>


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”/>


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()


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”/>


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>


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”)


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


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


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


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

1.request

2.session

3.pageContext

4.application


Question:
JSTL May be use the following TLD file 

1.c.tld

2.x.tld

3.fmt.tld

4.All of the above.


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


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


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


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.


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” %>


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” %>


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”/>


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


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


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


Question:
Which file extension is used for JSP files?

1..java

2.jspf

3.jsp

4.jsf


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 %>


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

1.<c:choose>

2.<c:if>

3. <c:when>

4.<c:case>


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>


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>


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

1.<c:function>

2.<c:defineFunction>

3.<c:fn>

4. <c:method>


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>


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>


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

1. <c:set>

2. <c:var>

3.<c:variable>

4. <c:define>


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

1. init()

2.service()

3.doGet()

4. jspInit()


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


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


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

1.<%@ %>

2.<%! %>

3. <%= %>

4. <%# %>


More MCQS

  1. JSTL MCQ OUESTIONS AND ANSWERS
  2. JNDI MCQ QUESTIONS AND ANSWER
  3. JNDI MCQ QUESTIONS AND ANSWER
Search
Olete Team
Online Exam TestTop Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on Online Exam Testwebsite 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!