JSTL(JSP Standard Tag Library) Interview Questions & Answers

5 avg. rating (100% score) - 1 votes

JSTL(JSP Standard Tag Library) Interview Questions & Answers

Want to shift your career to JSTL (JSP Standard Tag Library)? Then we in Wisdomjobs provide the complete information about where to apply for the JSTL (JSP Standard Tag Library) jobs on our site page as well as a different kind of job roles that we have in JSTL (JSP Standard Tag Library). To clear an interview, one must prepare well for the interview. There are many leading companies that offer job role like Senior Software Engineer, JavaDeveloper, Knowledge of performance tuning client-application code JSP, JSTL and many other roles too. One must work hard to clear any job it in first attempt. So simply to save your time we have provided all the necessary details about JSTL (JSP Standard Tag Library) Interview Questions and Answers and also various job role at one place.

JSTL(JSP Standard Tag Library) Interview Questions

JSTL(JSP Standard Tag Library) Interview Questions
    1. Question 1. What Is Jstl?

      Answer :

      The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags.

    2. Question 2. What Is A Taglib?

      Answer :

      JSP - The taglib Directive. Advertisements. The JavaServer Pages API allows you to define custom JSP tags that look like HTML or XML tags and a tag library is a set of user-defined tags that implement custom behavior. ... When you use a custom tag, it is typically of the form <prefix:tagname>.

    3. Question 3. What Is A Tag Library?

      Answer :

      The JavaServer Pages Standard Tag Library (JSTL) is a component of the Java EE Web application development platform. It extends the JSP specification by adding a tag library of JSP tags for common tasks, such as XML data processing, conditional execution, database access, loops and internationalization.

    4. Question 4. What Is Implicit Object?

      Answer :

      JSP Implicit Objects are the Java objects that the JSP Container makes available to developers in each page and developer can call them directly without being explicitly declared. JSP Implicit Objects are also called pre-defined variables.

    5. Question 5. What Are The Advantage Of Jstl?

      Answer :

      1. Fast Developement JSTL provides many tags that simplifies the JSP.
      2. Code Reusability We can use the JSTL tags in various pages.
      3. No need to use scriptlet tag It avoids the use of scriptlet tag.

    6. Question 6. How Many Tags Are Provided By Jstl? What Are They?

      Answer :

      There JSTL mainly provides 5 types of tags:

      1. Core tags.
      2. Function tags.
      3. Formatting tags.
      4. XML tags.
      5. SQL tags.

    7. Question 7. Explain Jstl Core Tags?

      Answer :

      JSTL Core tags provide support for iteration, conditional logic, catch exception, url, forward or redirect response etc. To use JSTL core tags, we should include it in the JSP page like below.

      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
      <pre class="prettyprint">

    8. Question 8. Explain Function Tags?

      Answer :

      Function tags: JSTL Functions Tags: JSTL tags provide a number of functions that we can use to perform common operation, most of them are for String manipulation such as String Concatenation, Split String etc. Syntax to include JSTL functions in JSP page is:

      <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

    9. Question 9. Explain Formatting Tags?

      Answer :

      Formatting tags: JSTL Formatting tags are provided for formatting of Numbers, Dates and i18n support through locales and resource bundles. We can include these jstl tags in JSP with below syntax:

      <pre class="prettyprint">

      <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

    10. Question 10. Explain Xml Tags?

      Answer :

      JSTL XML Tags: JSTL XML tags are used to work with XML documents such as parsing XML, transforming XML data and XPath expressions evaluation. Syntax to include JSTL XML tags in JSP page is:

      <%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

    11. Question 11. Explain Sql Tags?

      Answer :

      SQL tags : JSTL SQL Tags: JSTL SQL Tags provide support for interaction with relational databases such as Oracle, MySql etc. Using JSTL SQL tags we can run database queries, we include these JSTL tags in JSP with below syntax:

      <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>

    12. Question 12. List Some Jstl Core Tags?

      Answer :

      JSTL Core Tags :

      1. <c:out> : To write something in JSP page, we can use EL also with this tag.
      2. <c:import> : Same as <jsp:include> or include directive.
      3. <c:redirect> : redirect request to another resource.
      4. <c:set> : To set the variable value in given scope.
      5. <c:remove> : To remove the variable from given scope.
      6. <c:catch> : To catch the exception and wrap it into an object.
      7. <c:if> : Simple conditional logic, used with EL and we can use it to process the exception from <c:catch>.
      8. <c:choose> : Simple conditional tag that establishes a context for mutually exclusive conditional operations, marked by <c:when> and <c:otherwise>.
      9. <c:when> : Subtag of <c:choose> that includes its body if its condition evalutes to 'true'.
      10. <c:otherwise> : Subtag of <c:choose> that includes its body if its condition evalutes to 'false'.

    13. Question 13. List Some Function Tags?

      Answer :

      JSTL Function Tags List :

      1. fn:contains() : It is used to test if an input string containing the specified substring in a program.
      2. fn:containsIgnoreCase() : It is used to test if an input string contains the specified substring as a case insensitive way.
      3. fn:endsWith() : It is used to test if an input string ends with the specified suffix.
      4. fn:escapeXml() :  It escapes the characters that would be interpreted as XML markup.
      5. fn:indexOf() : It returns an index within a string of first occurrence of a specified substring.
      6. fn:trim() : It removes the blank spaces from both the ends of a string.
      7. fn:startsWith() : It is used for checking whether the given string is started with a particular string value.
      8. fn:split() : It splits the string into an array of substrings.
      9. fn:toLowerCase() : It converts all the characters of a string to lower case.
      10. fn:toUpperCase() : It converts all the characters of a string to upper case.

       

       

       

    14. Question 14. List Some Formatting Tags?

      Answer :

      Formatting Tags Descriptions :

      1. fmt:parseNumber : It is used to Parses the string representation of a currency, percentage or number.
      2. fmt:timeZone : It specifies a parsing action nested in its body or the time zone for any time formatting.
      3. fmt:formatNumber : It is used to format the numerical value with specific format or precision.
      4. fmt:parseDate : It parses the string representation of a time and date.
      5. fmt:bundle : It is used for creating the ResourceBundle objects which will be used by their tag body.
      6. fmt:setTimeZone : It stores the time zone inside a time zone configuration variable.
      7. fmt:setBundle : It loads the resource bundle and stores it in a bundle configuration variable or the named scoped variable.
      8. fmt:message : It display an internationalized message.
      9. fmt:formatDate : It formats the time and/or date using the supplied pattern and styles.

    15. Question 15. List Some Jstl Sql Tags?

      Answer :

      1. sql:setDataSource: It is used for creating a simple data source suitable only for prototyping.
      2. sql:query: It is used for executing the SQL query defined in its sql attribute or the body.
      3. sql:update: It is used for executing the SQL update defined in its sql attribute or in the tag body.
      4. sql:param: It is used for sets the parameter in an SQL statement to the specified value.
      5. sql:dateParam: It is used for sets the parameter in an SQL statement to a specified java.util.Date value.
      6. sql:transaction:  It is used to provide the nested database action with a common connection.

    16. Question 16. Explain Jstl If Tag With An Example?

      Answer :

      The if tag is a conditional tag used to evaluate conditional expressions. When a body is supplied with if tag, the body is evaluated only when the expression is true. For Example :

      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

      <html>
        <head>
          <title>Tag Example</title>
        </head>
        <body>
            <c:if test="${param.name == 'studytonight'}">
           <p>Welcome to ${param.name} </p>
          </c:if>
        </body>
      </html>

    17. Question 17. Explain Jstl Foreach Tag With An Example?

      Answer :

      JSTL forEach tag: This tag provides a mechanism for iteration within a JSP page. JSTL forEach tag works similarly to enhanced for loop of Java Technology. You can use this tag to iterate over an existing collection of items. For Example :

      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

      <html>
        <head>
          <title>Tag Example</title>
        </head>
        <body>
            <c:forEach var="message" items="${errorMsgs}" >
              <li>${message}</li>
            </c:forEach>
        </body>
      </html>

      Here the attribute items has its value as an EL expression which is a collection of error messages. Each item in the iteration will be stored in a variable called message which will be available in the body of the forEach tag.

    18. Question 18. Explain Jstl Catch Tag With An Example?

      Answer :

      JSTL catch tag: The JSTL catch tag is used to handle exception and doesn't forward the page to the error page. For Example :

      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

      <html>
        <head>
          <title>Tag Example</title>
        </head>
        <body>
          <c:catch>
            <% int a = 0;
               int b = 10;
               int c = b/a;
            %>
           </c:catch>
        </body>
      </html>

    19. Question 19. Explain Jstl Choose, When, Otherwise Tag With An Example?

      Answer :

      JSTL choose, when, otherwise tag: These are conditional tags used to implement conditional operations. If the test condition of the when tag evaluates to true, then the content within when tag is evaluated, otherwise the content within the otherwise tag is evaluated.

      We can also implement if-else-if construct by using multiple when tag. The when tags are mutually exclusive, that means the first when tag which evaluates to true is evaluated and then, the control exits the choose block. If none of the when condition evaluates to true, then otherwise condition is evaluated. For Example

      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
      <html>
        <head>
          <title>Tag Example</title>
        </head>
        <body>
          <c:forEach var="tutorial" items="${MyTutorialMap}" begin="0" end="5" varStatus="status">
                 <c:choose>    
              <c:when test="${status.count %2 == 0 }">
       <p> Divisible by 2 : ${tutorial.key} </p>
       <br/>
              </c:when>
              <c:when test="${status.count %5 == 0 }">
       <p > Divisible by 5 : ${tutorial.key} </p>
       <br/>
              </c:when>
              <c:otherwise>
       <p> Neither divisible by 2 nor 5 : ${tutorial.key} </p><br/>
              </c:otherwise>
           </c:choose>
          </c:forEach>
        </body>
      </html>

    20. Question 20. Explain Jstl Out Tag?

      Answer :

      JSTL out tag: The out tag is used to evaluate an expression and write the result to JspWriter. For Example :

      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
      <html>
        <head>
          <title>Tag Example</title>
        </head>
        <body>
            <c:out value="${param.name}" default="StudyTonight" />
        </body>
      </html>

      The value attribute specifies the expression to be written to the JspWriter. The default attribute specifies the value to be written if the expression evaluates null.

Jsp Tutorial

Jstl(jsp Standard Tag Library) Interview Questions

Jstl(jsp Standard Tag Library) Practice Tests


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JSP Tutorial