ArticleslgStudy

computer science

OGNL

OGNL is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand OGNL rather than just read about it. In short: 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 of methods of Java classes. It also allows for simpler array manipulation.

Key takeaways

  • OGNL belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect OGNL to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of OGNL from memory before moving on to harder problems.

Reference excerpt

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 of methods of Java classes. It also allows for simpler array manipulation. It is aimed to be used in Java EE applications with taglibs as expression language. OGNL was created by Luke Blanshard and Drew Davidson of OGNL Technology. OGNL development was continued by OpenSymphony, which closed in 2011. OGNL is developed now as a part of the Apache Commons.

OGNL Technology OGNL began as a way to map associations between front-end components and back-end objects using property names. As these associations gathered more features, Drew Davidson created Key-Value Coding language (KVCL). Luke Blanshard then reimplemented KVCL using ANTLR and started using the name OGNL. The technology was again reimplemented using the Java Compiler Compiler (JavaCC). OGNL uses Java reflection and introspection to address the Object Graph of the runtime application. This allows the program to change behavior based on the state of the object graph instead of relying on compile time settings. It also allows changes to the object graph.

Projects using OGNL WebWork and its successor Struts2 Tapestry (4 and earlier) Spring Web Flow Apache Click MyBatis - SQL mapper framework The Thymeleaf - A Java XML/XHTML/HTML5 template engine FreeMarker - A Java template engine

OGNL security issues Due to its ability to create or change executable code, OGNL is capable of introducing critical security flaws to any framework that uses it. Multiple Apache Struts 2 versions have been vulnerable to OGNL security flaws. As of October 2017, the recommended version of Struts 2 is 2.5.13. Users are urged to upgrade to the latest version, as older revisions have documented security vulnerabilities — for example, Struts 2 versions 2.3.5 through 2.3.31, and 2.5 through 2.5.10, allow remote attackers to execute arbitrary code. Atlassian Confluence has repeatedly been affected by OGNL security issues that allowed arbitrary remote code execution, and required all users to update.

See also

MVEL

External links OGNL 3.x maintenance branch OGNL 4.x Homepage (Apache) Apache Struts CVE-2013-2134 OGNL Expression Injection Vulnerability Archived 2021-05-09 at the Wayback Machine

References

Worked examples

Example 1 — a first encounter with OGNL

Start with the simplest possible case. Write down what OGNL claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to OGNL before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about OGNL ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of OGNL

In research
OGNL appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses OGNL in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
OGNL is common in secondary-school and first-year university syllabi. It links to neighbouring topics Apache Commons, Free software programmed in Java, Java (software platform), so understanding it makes those chapters shorter.
In everyday life
Look for OGNL outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study OGNL in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what OGNL means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain OGNL out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is OGNL in simple terms?

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 JavaB…

Why does OGNL matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study OGNL?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on OGNL.

Tags

  • Apache Commons
  • Free software programmed in Java
  • Java (software platform)
  • Programming language topic stubs
  • Scripting languages
  • Software using the BSD license

Keep exploring