aspose file tools*
The moose likes JSP and the fly likes convert scriptlet code into Expression language or JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "convert scriptlet code into Expression language or JSTL" Watch "convert scriptlet code into Expression language or JSTL" New topic
Author

convert scriptlet code into Expression language or JSTL

jaid shaik
Greenhorn

Joined: Jan 18, 2013
Posts: 3
Hi,
I am working on jsp pages,
in jsp pages i need to change scriptlets to JSTL tags or Expression language

I am new to jstl
how to change below code in to JSTL





Thanks

Gopakumar Naryanan
Ranch Hand

Joined: Jan 15, 2011
Posts: 72

jaid shaik wrote:Hi,



Looks like you are checking whether 'heightUnit' is not NULL and heightUnit equals "meters/cm" ..

If what i understood is correct, you can do it as follows:


Hope the above code will work .


Thanks & Regards
Gopakumar
jaid shaik
Greenhorn

Joined: Jan 18, 2013
Posts: 3
Hi gopakumar,

Thanks for reply....

can i use like this......




please let me know....

thanks
Gopakumar Naryanan
Ranch Hand

Joined: Jan 15, 2011
Posts: 72

No.. It won't work if you write so.

I meant you can directly write like this :

Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
If all the ValidatorUtil is doing is checking for null explicitly, then that substitution is ok.
EL also handles nulls better than regular java, so the null check is not necessary in the EL expression.
So my interpretation would be: ${heightUnit eq 'meters/cm' ? true : false}



These examples result in:
false - val1 is not equal to meters/cm
true - val2 is equal
false - val3 is null (not set as an attribute on the page)


On the other hand if Validator is doing more than a simple null check (e.g. removing all spaces from a string and THEN checking for null/empty) then you need to duplicate that functionality, or call it via an EL function. You can quite easily invoke static functions like this from EL.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: convert scriptlet code into Expression language or JSTL