Oracle GlassFish Server 3.0.1 Scripting Framework Guide

ProcedureTo Create the Views That Display the Images Generated by Java2D Code

In this task, you will perform the following actions:

  1. Find a JPEG image that you can use with this application.

  2. Add the image to imageprocess/public/image file.

  3. Change to imageprocess/app/views/home directory.

  4. Open the index.html.erb file in a text editor.

  5. Replace the contents of this file with the following HTML markup:


    <html>
    	<body>
    		<img src="../../images/kids.jpg"/><p>
    		<%= link_to "Perform a ColorConvertOp on this image", :action => "seeimage" %>
    	</body>
    </html>

    This page loads an image from imageprocess/public/images and provides a link that references the seeimage action. The seeimage action maps to the seeimage view, which shows the processed image.

  6. Replace kids.jpg in the index.html.erb with the name of your image that you saved earlier in this procedure.

  7. Save the index.html.erb file.

  8. Open the seeimage.html.erb file in a text editor.

  9. Replace the contents of this file with the following HTML markup:


    <html>
    	<body>
    		<img src="/home/processimage"/><p>
    		<%= link_to "Back", :action => "index" %>
    	</body>
    </html>

    The img tag on this page accesses the processimage action in HomeController. The processimage action is where you will put the Java2D code to process the image that you loaded into index.html.erb.