aspose file tools*
The moose likes JSP and the fly likes JSP 2.0 EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP 2.0 EL" Watch "JSP 2.0 EL" New topic
Author

JSP 2.0 EL

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

I noticed something strange. Both of the following output the same information:

and if I simply do:

I know that EL works inside of JSTL for other reasons, but for simply printing something out using c ut, why use JSTL? Why not just use EL all alone?
Another interesting I noticed..I loaded a properties file and accessed an attribute using the EL. The sample properties file looks like:
template.properties

I then load this into the request like

Now, when I access the "name" property using EL like:

I get printed on the screen

However, if I use EL without JSTL I get Gregg rendered as HTML (big and bold).
Does anyone know why this is?
[ January 01, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

<cut> is redundant in JSP 2.0 since you can use the EL directly in the template text.
In JSP 1.2, <cut> is the means to emit EL output.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
And there you aptly demonstrate why cut is not quite redundant. Sometimes you need to write outout (including HTML) directly to the output stream with no translation. Sometimes you want to make sure that any "dangerous" characters in user data are escaped so they don't screw up the page layout.
imagine my user data contains the following:
for (i = 0; i < n; ++i)
For unprotected output you can use EL directly (or you can use <%= ... %>).
For protected output you can use cut


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Originally posted by Frank Carver:
And there you aptly demonstrate why c ut is not quite redundant. Sometimes you need to write outout (including HTML) directly to the output stream with no translation. Sometimes you want to make sure that any "dangerous" characters in user data are escaped so they don't screw up the page layout.
imagine my user data contains the following:
for (i = 0; i < n; ++i)
For unprotected output you can use EL directly (or you can use <%= ... %> .
For protected output you can use c ut

I see. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Good info Frank! Having not had a chance to actually play with JSP 2 (just done lots of reading) I was not aware that the "embedded" EL didn't go through the encoding that <cut> provides.
bear
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP 2.0 EL