Use JSTL in JSP Page (original) (raw)

In this example we shall show you how to use JSTL in a JSP page. The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications. The JSTL tags can be classified, according to their functions, into Core tags, Formatting tags, SQL tags and XML tags and they can be used when creating a JSP page. To include JSTL in a JSP page one should perform the following steps:

as described in the code snippet below.

SimpleJSTL.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8" %> <%@ taglib uri="/WEB-INF/tld/c-rt.tld" prefix="c-rt" %>

Java Code Geeks Snippets - Simple JSTL in JSP Page
<c-rt:if test='<%= request.getParameter("myparam") != null %>'>
    <%= request.getParameter("myparam") %>
</c-rt:if>

URL:

http://localhost:8080/jcgsnippets/SimpleJSTL.jsp?myparam=myvalue

Output:

myvalue

This was an example of how to use JSTL in a JSP page.

Photo of Ilias Tsagklis

Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.

Back to top button