Difference between revisions of "Lab B.1: Hello World"
imported>Aeric |
imported>Aeric |
||
Line 22: | Line 22: | ||
:{| border="1" cellpadding="5" cellspacing="1" | :{| border="1" cellpadding="5" cellspacing="1" | ||
! Conditional display of HTML !! Loops for repeated HTML | ! align="left"| Conditional display of HTML !! align="left"| Loops for repeated HTML | ||
|- | |- | ||
| | | | ||
<tt><nowiki><% if (…) { %> | <tt><nowiki><% if (…) { %></nowiki></tt><br> | ||
<tt> ... HTML ... </tt><br> | |||
<% } %> | <tt><nowiki><% } %></nowiki></tt> | ||
</nowiki></tt> | |||
| | | | ||
<tt><nowiki><% for (item:List) { %> | <tt><nowiki><% for (item:List) { %></nowiki></tt><br> | ||
<tt> ... HTML ... </tt><br> | |||
<% } %> | <tt><nowiki><% } %></nowiki></tt> | ||
</nowiki></tt> | |||
|} | |} | ||
Revision as of 22:57, 3 August 2012
- Goals
-
- Set up a development environment
- Create a JSP page
- Visit the page in the platform
- Prerequisites
-
- Read the Application Architecture overview.
Exercise
Overview: JSP Pages
A Java Server Page (JSP) is an HTML file that contains Java code. If no Java code happens to be present, then the "JSP" page contains nothing but HTML. (In the platform, they are called simply Pages, since they can be either HTML pages or JSP pages.)
The Many Uses of JSP Pages
Interact with the Platform Work with your data�
JSP Basics
The are only a few patterns you need to know to do some serious work with JSP pages:
- <% … code … %> -- execute some code
- <%= variable %> -- insert data into the HTML stream
Conditional display of HTML Loops for repeated HTML <% if (…) { %>
... HTML ...
<% } %><% for (item:List) { %>
... HTML ...
<% } %>
Set up a development environment
- In the navigation pane, click Setup.
- If you don't see an entry called Develop, then:
- Set up Developer Privileges
- Log in again
Create a JSP Page
- Click Designer > Pages > [New Page]
Note: If this is the first development activity to occur, you may see an error message like the following at the top of the screen:
To create a new class, page, or execute Java code in Data Policies, namespace needs to be set in Company Information. Click here ...
The link takes you to the Developer Configuration page, where you can specify your organization's namespace--typically, the company name or an abbreviation of it that corresponds to the company URL. (The lab exercises use "demo".)
- Enter the page name: HelloWorld.jsp
Note: It is necessary to add the .jsp extension when specifying the page name. - Add content for the page:
<h1 align="center">Hello World!</h1>
- Click [Save]
Visit the page to confirm that it exists
- In your web browser, visit https://{platform}/networking/pages/HelloWorld.jsp, substituting your platform URL for "{platform}".
- The page you created appears.