alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Struts example source code file (ognl_3.jsp)

This example Struts source code file (ognl_3.jsp) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Struts tags/keywords

book, do, do, http, if, iliad, iliad, maps, note, ognl, ognl, pragma, to, to

The Struts ognl_3.jsp source code

<%
    request.setAttribute("decorator", "none");
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<p>
    <b>Accessing properties inside Maps
</p>
<p>
    To access properties inside maps, use the brackets "[]" operators with the desired key. The action
    class has a map of Book objects in the field <i>books.
</p>
<p>
    To access the book with key "Iliad" in the <i>books map type:
</p>
<p>
    <i id="example0">
        books['Iliad']
    </i>
</p>
<p>
    on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example0')">Do it for me
</p>
<p>If the key does not have spaces in it, you can access an element in the map, using the dot "." operator.

<p> To access the book with key "Iliad" in the <i>books map type: </p> <p> <i id="example1"> books.Iliad </i> </p> <p> on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example1')">Do it for me </p> <p> Note that the object returned is of type Book. If you want to access one of its properties, you can do so using the dot "." operator as you did before.</p> <p> To access the <i>author property of the book with key "Iliad" in the books map type: </p> <p> <i id="example2"> books['Iliad'].author </i> </p> <p> on the OGNL console and hit enter. <a href="#" onclick="execOgnl('example2')">Do it for me </p> <br/> <p> <a href="#" onclick="window.open('http://www.ognl.org/2.6.9/Documentation/html/LanguageGuide/indexing.html#N10184')">[More details] </p>

Other Struts examples (source code examples)

Here is a short list of links related to this Struts ognl_3.jsp source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.