Exact difference and relation between JSTL and Expression Language
Asked Answered
S

1

23

After reading the Q&A How to avoid Java code in JSP files? I stopped coding with scriptlets.

So started reading JSTL and got a doubt that I found JSTL is have a relation with EL.

But I am not getting the exact relation between them.

Here I got the code from here

 <c:set var="test" value="JSTL Core Tags"></c:set>
 <c:out value="${test}"></c:out>

I know <c:set is a JSP tag and ${test} is Expression language ..

My confusions are

  1. Won't working with JSTL alone work? Does it always need the support of EL ? If not always needed, how in the above case?

  2. How to simply use the Expression language without JSTL tags?

Southeastward answered 6/4, 2013 at 7:30 Comment(2)
EL is a means of manipulating server-side content, be it within JSTL tags, or in a 'plain' style. If used within a tag, it can be used to get data, like in your example, or set data, as in the case of, for example, <h:inputText>.Glyceride
This may be helpful: #4813255Trimmer
R
31

The EL, initially, has been designed to be used inside attributes of the JSTL tags, and any other custom tag you might want to use or write yourself.

A later version of the JSP spec has allowed using the EL directly inside the JSPs, but this doesn't mean the JSTL isn't useful anymore. The only thing you can do with EL directly in the JSP is to write some value to the response like for example

${user.id}

which would write the ID of the user bean. If you want tests, loops, HTML escaping, URLs, date an number formatting, etc., you still need to use the JSTL.

Raceway answered 6/4, 2013 at 9:26 Comment(1)
Also El is not code injection proof.Homer

© 2022 - 2024 — McMap. All rights reserved.