Take the 2-minute tour ×

I am studying JSTL part of JSP, I have a question about the <c:forEach> loop tag. Is that c prefix required? Does it indicate any specification?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

Tag libraries in JSP are identified by tag library URIs. When you use a tag library in your JSP page, you import a tag library by its URI and bind it to some prefix:


After that you use the specified prefix to indentify tags from that library:

<c:foreach ...>

EDIT: These prefixes can be arbitrary, but there is a convention to use a value of the <short-name> field in the tag library definition file (it's where c for JSTL Core comes from)

share|improve this answer
Keeping convention is important, as it makes the tags readable without having to check the top bindings all the time. –  Thorbjørn Ravn Andersen Jan 31 '10 at 20:40

You need some prefix, but it doesn't have to be c:, that's just the convention. The prefix is specified when you declare the tag library at the top of the JSP, and it can be anything you like (within reason). The important part is the namespace URI (also specified in the JSP header), and that has to be a specific value (http://java.sun.com/jsp/jstl/core in this case).

But you must have a prefix of some form, otherwise the JSP engine won't recognise it.

share|improve this answer

Your Answer


