Question

I want to write a simple web page in .jsp file. I need to use <c:if> tag. but it is not recognized. eclipse said it is unknown tag.

I googled it and some said I need to include the standard lib (which is JSTL?).

I just want to use some basic tags in jsp file such as <c:if>. Do I really need to include any libraries? If so, what libraries do I need to include? And how to do that in Eclipse? Please let me know step by step about how to import/include these libraries or build path so that I can use <c:if> in my jsp file.

Was it helpful?

Solution

Make sure that you have a taglib declaration in your JSP file

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

Also, make sure that you've added JSTL jar files to your project classpath.

OTHER TIPS

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

<HTML>
 <HEAD><TITLE>JSTL 'if' tag</TITLE></HEAD>
 <BODY>
  <c:if test="true">Hello world!</c:if>
 </BODY>
</HTML>

Source: http://www.java2s.com/Code/Java/JSTL/JSTLiftag.htm

You need to see this link JSTL tag library to select the right libraries version and its header:

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

or

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

add this tag..

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

and copy this two jar file in your project folder web-inf->lib

javax.servlet.jsp.jstl-1.2.1.jar javax.servlet.jsp.jstl-api-1.2.1.jar

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top