Say that I don't leverage OGNL to create my Struts2 web application and just purely uses typical el provided by Sun. What would be the downside of it?
As far as I know, OGNL is a kind of expression which attempts to match the best matched value from ValueStack based on its current state. Could it also be achieved by just using EL alone instead?
Thanks in advance for the responses
Daniel
OGNL is the Object Graph Navigation Language (see [http://commons.apache.org/proper/commons-ognl/] for the full documentation of OGNL).
ValueStack/OGNL Example Actually, Struts 2 adds your action to the top of the valueStack when executed. So, the usual way to put stuff on the Value Stack is to add getters/setters for the values to your Action class and then use <s:property> tag to access the values.
Object-Graph Navigation Language (OGNL) is an open-source Expression Language (EL) for Java, which, while using simpler expressions than the full range of those supported by the Java language, allows getting and setting properties (through defined setProperty and getProperty methods, found in JavaBeans), and execution ...
Object-Graph Navigation Language is an open-source Expression Language (EL) for Java objects. Specifically, OGNL enables the evaluation of EL expressions in Apache Struts, which is the commonly used development framework for Java-based web applications in enterprise environments.
Short Answer: Yes, you can use the JSP EL instead of OGNL. Both languages have their pros and cons, but there is no looming downside to using either.
Long Answer: OGNL is used internally by XWork and Struts2, so you can't actually remove the dependency itself, however you can certainly use the JSP EL predominantly (or even exclusively) in your JSP view layer.
There are pros and cons to using either expression language. One area that OGNL shines over the JSP EL is in dynamic creation of maps and collections, such as for backing <select/>
elements, etc.
However, in most cases I find that the JSP EL is a better fit for me since I make heavy use of JSP simple tags (.tag
files).
@Amit Sharma: I have to disagree that using JSP/JSTL over OGNL and the Struts tags defeats the purpose of using Struts2. The interceptor framework, type conversion, and result types are among the most extensible and compelling reasons to use Struts2. None of those things are tied to any specific view technology.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With