What does a $ symbol mean in a JSP
Asked Answered
T

3

7

First of all, please bare my ignorance. This may be a very basic question. But I am not to find it out.

I see some thing like this in the code. I dont understand what a JSTL is. Whatever I search, it redirects to JSTL related articles, which I seldom understand !

${applicationVersionNumber}

What does this mean ? From where this value is read ? Any help is highly appreciated.

Also I see the below on top of my file. Which one of these three lines is actually required for ${applicationVersionNumber} to work ?

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://jakarta.apache.org/taglibs/log-1.0" prefix="log"%>
Thud answered 20/12, 2011 at 9:24 Comment(2)
Put your mouse above either of the [jsp][jstl][el] tags below the question. In the popbox which shows, click the info link.Cloudland
Also, what does <%@ mean?Marotta
E
3

None of the taglib is necessary as it is a JSP 2.0 standard.

It just print the content of the variable in the document.

For more details about the EL expressions, this is the documentation you're looking for: http://java.sun.com/products/jsp/syntax/2.0/syntaxref207.html#1010522

Eon answered 20/12, 2011 at 9:27 Comment(3)
"EL" is short for "Expression Language". See en.wikipedia.org/wiki/Unified_Expression_LanguagePeignoir
link broke, now at: download.oracle.com/otn-pub/jcp/jsp-2.1-fr-eval-spec-oth-JSpec/…Dumfound
Seems like this other link is not accessible anymore!Bile
P
2

AFAIK From JSP 2.0 the pattern ${ } is declared that identifies EL expressions. In short EL expressions are enclosed by the ${ } characters.

${applicationVersionNumber} What does this mean ?

This will print/refer to value of applicationVersionNumber.

Which one of these three lines is actually required for ${applicationVersionNumber} to work ?

None of them.

Peshawar answered 20/12, 2011 at 9:30 Comment(1)
Yes, no taglibs. It's not part of the JSTL but JSP 2.0Eon
F
2

The dollar symbol is just for printing the value of the variable. Its just a short cut for a scriplet that prints . It relies on Java Bean specs and it is same as ".get"

One major difference between using $ and scriplet is EL is null safe, whereas scriplets are not.

Filigreed answered 28/12, 2011 at 15:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.