| <?xml version="1.0"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <!--+ |
| | Simple XSP example. |
| | $Id$ |
| +--> |
| <xsp:page language="java" |
| xmlns:xsp="http://apache.org/xsp" |
| xmlns:xsp-request="http://apache.org/xsp/request/2.0" |
| xmlns:log="http://apache.org/xsp/log/2.0" |
| xmlns:capture="http://apache.org/cocoon/capture/1.0" |
| xmlns:input="http://apache.org/cocoon/xsp/input/1.0"> |
| |
| <xsp:logic> |
| void sayHello(int n) throws SAXException { |
| <ul> |
| <xsp:logic> |
| for (int i = 0; i < n; i++) { |
| <li>Hello world <xsp:expr>i+1</xsp:expr></li> |
| } |
| </xsp:logic> |
| </ul> |
| } |
| </xsp:logic> |
| |
| <page> |
| <!-- Use own logger sub-category for this logicsheet --> |
| <log:logger name="simple"/> |
| <log:debug>Processing the beginning of the page</log:debug> |
| |
| <title>A Simple XSP Page</title> |
| |
| <content> |
| <capture:fragment-variable name="page_part"> |
| <para> |
| These 2 paragraphs were generated at the start of the XSP, |
| and captured for insertion at the end. |
| </para> |
| <para>Brought to you by Cocoon at <xsp:expr>new Date()</xsp:expr>.</para> |
| </capture:fragment-variable> |
| |
| <para>Hi there! I'm a simple dynamic page generated by XSP (eXtensible Server Pages).</para> |
| |
| <para>I was requested as the URI: <b><xsp-request:get-uri as="xml"/></b></para> |
| |
| <para>The following list was dynamically generated:</para> |
| <ul> |
| <xsp:logic> |
| for (int i=0; i < 3; i++) { |
| <li> |
| Item <xsp:expr>i</xsp:expr> |
| </li> |
| } |
| </xsp:logic> |
| </ul> |
| |
| <para>The following list was generated by a subroutine:</para> |
| <xsp:logic> |
| sayHello(3); |
| </xsp:logic> |
| |
| <xsp:element> |
| <xsp:param name="name"><xsp:expr>"P".toLowerCase()</xsp:expr></xsp:param> |
| <xsp:attribute name="align">left</xsp:attribute> |
| <i> |
| This paragraph was dynamically generated by logic embedded in the page |
| </i> |
| </xsp:element> |
| |
| <para> |
| Request parameter "name" as XML: |
| <xsp-request:get-parameter name="name" default="Not provided" as="xml"/> |
| </para> |
| |
| <para> |
| Request parameter "name" as String: |
| <xsp-request:get-parameter name="name" default="Not provided"/> |
| </para> |
| |
| <para> |
| Request parameter "name" as iso-8859-2 encoded String (with servlet |
| container encoding iso-8859-1): |
| <xsp-request:get-parameter name="name" default="Not provided" |
| form-encoding="iso-8859-2" container-encoding="iso-8859-1"/> |
| </para> |
| |
| <xsp-request:get-parameter-values name="name"/> |
| <xsp-request:get-parameter-names/> |
| |
| <para> |
| Header "user-agent" as XML: |
| <xsp-request:get-header name="user-agent" as="xml"/> |
| </para> |
| |
| <para> |
| Header "user-agent" as String: |
| <xsp-request:get-header name="user-agent"/> |
| </para> |
| |
| <para> |
| Access to input modules configured in cocoon.xconf: |
| <input:get-attribute module="cocoon-properties" name="fullname"/> |
| <input:get-attribute module="cocoon-properties" name="version"/> |
| </para> |
| |
| <xsp-request:get-header-names/> |
| |
| <xsp:expr>page_part</xsp:expr> |
| </content> |
| |
| <log:debug>Processing the end of the page</log:debug> |
| </page> |
| </xsp:page> |