Data AccessCore JavaApp FrameworksViewTestingBuildingDeploymentDev ToolsSecurityOpinions

Tuesday, September 8, 2009

Accessing HTTP Header with OGNL

OGNL stands for Object-Graph Navigation Language; it is an expression language for getting and setting properties of Java objects. You use the same expression for both getting and setting the value of a property.

Struts2 adds on top of OGNL by providing support for a 'Value Stack'. While OGNL operates under the assumption there is only one "root", XWork's ValueStack concept requires there be many "roots". Have a quick read on OGNL basics.

When referring to non-root objects are accessed with a (#) sign.

Accessing an HTTP Header can be achieved by the following code.
<s:property value="#header.myHeaderPropKey"/> or
<s:property value="#header['myHeaderPropKey']"/> or

3 comments: