Repository: groovy-examples Updated Branches: refs/heads/master 400778382 -> 3bd1e1811
http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/Animal.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/Animal.groovy b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/Animal.groovy new file mode 100644 index 0000000..49e13e9 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/Animal.groovy @@ -0,0 +1,23 @@ +/* + * 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. + */ +interface Animal { + + String saySomething(String something); + +} http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/Fish.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/Fish.groovy b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/Fish.groovy new file mode 100644 index 0000000..1c58730 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/Fish.groovy @@ -0,0 +1,27 @@ +/* + * 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. + */ +package zoo + +abstract class Fish implements Animal { + + String saySomething(String something) { + return "Blubb�: " + something + "..." + } + +} http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Shark.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Shark.groovy b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Shark.groovy new file mode 100644 index 0000000..8f05925 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Shark.groovy @@ -0,0 +1,29 @@ +/* + * 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. + */ +package zoo.fish + +import zoo.Fish + +class Shark extends Fish { + + String saySomething(String something) { + return "Shark bites " + something + "...ROOOAR�!" + } + +} http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Trout.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Trout.groovy b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Trout.groovy new file mode 100644 index 0000000..0b19518 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/WEB-INF/groovy/zoo/fish/Trout.groovy @@ -0,0 +1,27 @@ +/* + * 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. + */ +package zoo.fish + +class Trout extends zoo.Fish { + + String saySomething(String something) { + return "Trout says " + something + "...blubb�!" + } + +} http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/WEB-INF/web.xml b/src/main/groovy/webapps/groovlet-examples/WEB-INF/web.xml new file mode 100644 index 0000000..cd22859 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/WEB-INF/web.xml @@ -0,0 +1,89 @@ +<!-- + + 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. + +--> +<web-app xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_3.xsd" + version="2.3"> + + <servlet> + <servlet-name>Groovlet</servlet-name> + <servlet-class>groovy.servlet.GroovyServlet</servlet-class> + <init-param> + <param-name>verbose</param-name> + <param-value>true</param-value> + </init-param> + <init-param> + <param-name>resource.name.regex</param-name> + <param-value>none</param-value> + </init-param> + <init-param> + <param-name>resource.name.replacement</param-name> + <param-value>none</param-value> + </init-param> + </servlet> + + <servlet> + <servlet-name>Template|GSP</servlet-name> + <servlet-class>groovy.servlet.TemplateServlet</servlet-class> + </servlet> + + <servlet> + <servlet-name>Template|GString</servlet-name> + <servlet-class>groovy.servlet.TemplateServlet</servlet-class> + <init-param> + <param-name>template.engine</param-name> + <param-value>groovy.text.GStringTemplateEngine</param-value> + </init-param> + </servlet> + + <servlet> + <servlet-name>Template|XML</servlet-name> + <servlet-class>groovy.servlet.TemplateServlet</servlet-class> + <init-param> + <param-name>template.engine</param-name> + <param-value>groovy.text.XmlTemplateEngine</param-value> + </init-param> + </servlet> + + <servlet-mapping> + <servlet-name>Template|GSP</servlet-name> + <url-pattern>*.html</url-pattern> + </servlet-mapping> + + <servlet-mapping> + <servlet-name>Template|XML</servlet-name> + <url-pattern>*.xhtml</url-pattern> + </servlet-mapping> + + <servlet-mapping> + <servlet-name>Groovlet</servlet-name> + <url-pattern>*.groovy</url-pattern> + </servlet-mapping> + + <welcome-file-list> + <welcome-file>index.xhtml</welcome-file> + <welcome-file>index.html</welcome-file> + <welcome-file>index.jsp</welcome-file> + <welcome-file>index.jspx</welcome-file> + <welcome-file>index.groovy</welcome-file> + </welcome-file-list> + +</web-app> http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/codehaus-style.css ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/codehaus-style.css b/src/main/groovy/webapps/groovlet-examples/codehaus-style.css new file mode 100644 index 0000000..86667ce --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/codehaus-style.css @@ -0,0 +1,626 @@ +/* + * 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. + */ +body { + font-family: Verdana, Helvetica, Arial, sans-serif; + font-size: small; + margin: 0; +} + +div { + /* line-height: 1.5em; */ +} + +a { + color: #008800; + text-decoration: none; + font-weight: bold; +} + +.navLink a { + font-weight: normal; +} + +.navLink { + margin-left: 5px; +} + +.navLink:first-line { + margin-left: -5px; +} + + +a:link.selfref, a:visited.selfref { +} + +a:link, a:visited { +} + +a:active, a:hover { + text-decoration: underline; +} + +a.plain:active, a.plain:hover { + text-decoration: none; +} + +.sectionTitle a { + text-decoration: underline; +} +.subsectionTitle a { + text-decoration: underline; +} + +span.highlight { + font-weight: bold; + color: #990000; +} + +#layout { + margin: 0px; + padding: 0px; +} + +#banner { + padding: 8px; +} + +#breadcrumbs { + border-top: 1px solid #009900; + border-bottom: 1px solid #009900; + padding-left: 12px; + padding-right: 12px; + padding-top: 2px; + padding-bottom: 2px; + font-size: x-small; + background-color: #dddddd; +} + +#breadcrumbs td { + font-size: x-small; +} + +#breadcrumbs a { + font-weight: bold; +} + +#layout { + /*border-top: 1px solid #009900;*/ + padding: 0px; + margin: 0px; + +} + +.navSection { + background-color: #ffffff; + border: 1px solid #999999; + border-top: none; + padding: 0px; + margin-bottom: 8px; + font-size: small; +} + +.navSection a { + font-weight: normal; +} + +.navSectionHead { + border-top: 1px solid #999999; + border-bottom: 1px solid #999999; + color: #555555; + padding: 4px; + margin-left: 0px; + margin-right: 0px; + background-color: #eeeeee; + font-weight: bold; + font-size: x-small; +} + +.navLink { + padding-top: 2px; + padding-bottom: 2px; + padding-left: 14px; + font-size: small; +} + +.section { + padding-bottom: 16px; +} + +* + h1 { + margin-top: 1.5em; +} + +* + h2 { + margin-top: 1.5em; +} + +.sectionTitle, h1 { + padding: 4px; + border: 1px solid #aaaaaa; + color: #007700; + font-size: larger; + background-color: #eee; + color: #007700; + font-weight: bold; + margin-bottom: .5em; + /* margin-top: 1em; */ +} + +.subsection { + padding-left: 20px; + margin-top: 10px; + margin-bottom: 10px; +} + +body:first-child { + padding-top: 0px; +} + +.subsectionTitle, h2 { + padding-left: .2em; + /* margin-top: 1em; */ + margin-bottom: .5em; + border-bottom: 1px solid #999; + border-left: 1px solid #999; + background-color: white; + font-weight: bold; + font-size: larger; +} + +.sectionTitle a { + font-weight: normal; +} + +.subsectionTitle a { + font-weight: normal; +} + +.subsubsection { + padding-left: 30px; +} + +.subsubsectionTitle, h3, .blogheading { + font-weight: bold; + border-bottom: 1px solid #bbb; + padding: .1em; + color: #555; + margin-bottom: .5em; +} + +h4 { + margin-bottom: .5em; + padding: .1em; + border: 1px solid #ddd; + +} + +ins.inserted { + text-decoration: none; + font-weight: bold; +} + +#leftColumn { + width: 12em; +} + +#leftColumn h3 { + background-color: #ddd; + border: 1px solid #ccc; + border-bottom: 1px solid #070; + margin-bottom: .5em; +} + +#leftColumn a { + font-weight: inherit; +} + +#breadcrumbs a { + font-weight: inherit; +} + + +p { + margin: 0px; + margin-bottom: .5em; + line-height: 1.2em; + padding-right: 20px; + padding-left: 0px; +} + +blockquote p { + padding-left: 0px; + padding-right: 0px; +} + +ul { + margin-top: 1em; + margin-bottom: 1em; + padding-left: 1.5em; +} + +ul ul { + margin: 0px; + padding-left: 1em; +} + +li { + margin: 0px; + margin-right: 15%; + line-height: 1.2em; +} + +#leftColumn { + border-right: 1px solid #cccccc; + background-color: #eeeeee; + padding: 12px; + font-size: small; +} + +#leftColumn a { + font-size: smaller; +} + +#leftColumn tt a { + font-size: inherit; +} + +#leftColumn h3 a { + font-size: inherit; +} + +tt { + font-size: larger; +} + + +#extraColumn { + padding: 12px; +} + +#navBox { +} + +#rightColumn { + padding: 12px; + border-right: 1px solid #cccccc; + font-size: small; + padding-left: 16px; + padding-right: 16px; +} + +#contentBox { + +} + +table.bodyTable, table.wikitable { + margin: 10px; + border-collapse: collapse; + border-spacing: 0pt; + background-color: #eeeeee; +} + +#Content table.grid { + border: 1px solid #bbbbbb; +} + +table.grid { + padding: 0px; + border-collapse: collapse; + border-spacing: 0pt; + margin-left: 1em; + margin-right: 1em; +} + +table.grid th { + background-color: #eeeeee; + font-size: smaller; + padding: 4px; + border: 1px solid #bbbbbb; +} + +table.grid td { + font-size: x-small; + border: 1px solid #bbbbbb; + padding: 3px; +} + +table.bodyTable th, table.bodyTable td, table.wikitable th, table.wikitable td { + border: 1px solid #999999; + font-size: smaller; + padding: 4px; +} + + +table.bodyTable th, table.wikitable th { + text-align: left; + background-color: #dddddd; + border: 2px solid #999999; + padding: 4px; +} + +.nobr + white-space: nowrap; +} + +table.bodyTable td { + padding: 4px; +} + +/* +table.bodyTable th, table.wikitable th { + border-bottom: 2px solid #999999; +} + +table.bodyTable tr.a { + background-color: #dedede; +} + +table.bodyTable tr.b { + background-color: #efefef; +} +*/ + +.source, .code { + padding: 12px; + margin: 1em; + border: 1px solid #007700; + border-left: 2px solid #007700; + border-right: 2px solid #007700; + color: #555555; +} + +pre { + padding: 12px; + font-size: larger; +} + +.java-keyword { + color: #009900; +} + +.java-object { + color: #000099; +} + +.java-quote { + color: #990000; +} + + +.source, .code pre { + margin: 0px; + margin-left: 8px; + padding: 0px; +} + +#footer { + padding-left: 4px; + border-top: 1px solid #009900; + color: #888888; + font-size: x-small; +} + +blockquote { + border-top: 1px solid #bbbbbb; + border-bottom: 1px solid #bbbbbb; + border-left: 3px solid #bbbbbb; + border-right: 3px solid #bbbbbb; + padding: 12px; + margin-left: 3em; + margin-right: 3em; + color: #666666; + background-color: white; + line-height: 1.5em; +} + +input[type="text"] { + margin: 0px; + border: 1px solid #999999; + background-color: #dddddd; +} + +input.required { + margin: 0px; + border: 1px solid #990000; +} + +input { + border: 1px solid #999999; +} + +textarea { + border: 1px solid #999999; +} + +textarea.required { + border: 1px solid #990000; +} + +label { + font-size: smaller; +} + +label.required { + color: #990000; +} + +.searchResults { + color: black; +} + +.searchResults b { + color: #007700; +} + + +.linecomment { color: #bbbbbbb; } +.blockcomment { color: #bbbbbbb; } +.prepro { color: #0000BB; } +.select {} +.quote { color: #770000; } +.category1 { color: #007700; } +.category2 { color: #0000BB; } +.category3 { color: #0000BB; } + +#page_title { + border-bottom: 1px solid black; + font-weight: bold; + font-size: x-large; + margin-bottom: .5em; +} + +.greenbar { + background-color: green; +} + +.redbar { + background-color: red; +} + +tr.testpassed td { + padding: 0px; + padding-left: 1px; + padding-right: 1px; + margin: 0px; +} + +tr td.noformatting { + border: none; + padding: 0px; + padding-left: 4px; + padding-right: 4px; + margin: 0px; +} + +.greybox { + font-style: italic; + font-weight: bold; + margin-top: .5em; + margin-bottom: .5em; + background-color: #ddd; + border: 1px solid #bbb; + padding: .3em; +} + +.panelContent { + border: 1px solid #999; + padding: 1em; + margin: 1em; +} + +.header_name { + font-size: smaller; + padding: 2px; + padding-right: 1ex; + border-right: 1px solid #555; + background-color: #ccc; +} + +.header_value { + font-size: smaller; + background-color: #ddd; + padding: 2px; +} + +.header_fields { + width: 100%; + border: 1px solid #999; + background-color: #fff; +} + +.email_body { + margin: 2ex; + padding: 1ex; + padding-left: 2ex; + padding-right: 2ex; + border: 1px solid #999; + font-size: smaller; +} + +.email_body pre { + padding: 0px; + margin: 0px; +} + +.email_body blockquote { + padding: 0px; + margin: 0px; + border: 1px solid #ccc; +} + +.msg_navblock { + margin-bottom: 2ex; + border: 1px solid #999; + background-color: #fff; +} + +.msg_navblock th { + border: 1px solid #ccc; + font-size: smaller; +} + +.msg_navblock td { + border: 1px solid #ccc; + font-size: smaller; +} + +.single_entry { + border: 1px solid #aaa; + padding: .5ex; + padding-left: 1ex; + border-left: 1px solid #090; + margin: 2px; + background-color: #eee; +} + +.root_entry { + border: 1px solid #aaa; + padding: .5ex; + padding-left: 1ex; + border-left: 1px solid #090; + margin-top: 8px; + margin-bottom: 8px; + background-color: #eee; +} + +.root_entry .sub_entry { + padding: .5ex; + padding-left: 1ex; + margin: 2px; + margin-left: 1ex; + border-left: 1px solid #999; +} + +.list_entry { + border: 1px solid #aaa; + padding: 1ex; + margin-top: 1ex; + margin-bottom: 1ex; +} + +.list_entry td { + border: 1px solid #999; +} + +.project_entry { + border: 1px solid #aaa; + padding: 1ex; + margin-top: 1ex; + margin-bottom: 1ex; +} http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/hello/hello.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/hello/hello.groovy b/src/main/groovy/webapps/groovlet-examples/hello/hello.groovy new file mode 100644 index 0000000..85b8617 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/hello/hello.groovy @@ -0,0 +1,51 @@ +/* + * 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. + */ +println """ +<html> + <head> + <title>Groovy Servlet Example - hello</title> + </head> + <body> + <a href="../"><img src="../images/return.gif" width="24" height="24" border="0"></a><a href="../">Return</a> + <p> +""" + +session = request.getSession(true); + +if (session.counter == null) { + session.counter = 1 +} + + +println """Hello, ${request.remoteHost}! ${new java.util.Date()}""" + +println """ +<dl> + <dt><b>requestURI</b></dt><dd>${request.requestURI}</dd> + <dt><b>servletPath</b></dt><dd>${request.servletPath}</dd> + <dt><b>session.counter</b></dt><dd>${session.counter}</dd> +</dl> +""" + +println """ + </body> +</html> +""" + +session.counter = session.counter + 1 http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/images/code.gif ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/images/code.gif b/src/main/groovy/webapps/groovlet-examples/images/code.gif new file mode 100644 index 0000000..93af2cd Binary files /dev/null and b/src/main/groovy/webapps/groovlet-examples/images/code.gif differ http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/images/execute.gif ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/images/execute.gif b/src/main/groovy/webapps/groovlet-examples/images/execute.gif new file mode 100644 index 0000000..f64d70f Binary files /dev/null and b/src/main/groovy/webapps/groovlet-examples/images/execute.gif differ http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/images/groovy.png ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/images/groovy.png b/src/main/groovy/webapps/groovlet-examples/images/groovy.png new file mode 100644 index 0000000..54af4c1 Binary files /dev/null and b/src/main/groovy/webapps/groovlet-examples/images/groovy.png differ http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/images/return.gif ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/images/return.gif b/src/main/groovy/webapps/groovlet-examples/images/return.gif new file mode 100644 index 0000000..af4f68f Binary files /dev/null and b/src/main/groovy/webapps/groovlet-examples/images/return.gif differ http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/index.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/index.groovy b/src/main/groovy/webapps/groovlet-examples/index.groovy new file mode 100644 index 0000000..6a62dc6 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/index.groovy @@ -0,0 +1,107 @@ +/* + * 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. + */ +println """ + +<!-- Groovy Groovlet Examples. --> + +<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <meta name="Author" content="Groovy Developers"> + <title>Groovy - Groovlet Examples</title> + <link rel="stylesheet" href="codehaus-style.css" type="text/css"> +</head> + +<body bgcolor="#FFFFFF"> + +<a href="http://groovy.codehaus.org"><img src="images/groovy.png" border="0"></a> + +<h1>Groovlet examples showing GroovyServlet in action</h1> +<p> +These examples will only work when viewed via an http URL. They will not work +if you are viewing these pages via a <tt>file://...</tt> URL. You need to +deploy the <tt>war</tt> archive into a servlet container like Tomcat, Jetty or +any other will do as well. +</p> + +<p> +To navigate your way through the examples, the following icons will help: + +<table border=0> + <tr> + <td width="30"><img src="images/execute.gif" ></td> + <td>Executes the example</td> +</tr> +<tr> + <td width="30"><img src="images/code.gif"></td> + <td>Look at the source code for the example</td> +</tr> +<tr> + <td width="30"><img src="images/return.gif"></td> + <td>Return to this screen</td> +</tr> +</table> +</p> + +<p>Tip: To see the cookie interactions with your browser, try turning on +the "notify when setting a cookie" option in your browser preferences. +This will let you see when a session is created and give some feedback +when looking at the cookie demo. +</p> + +<h2>Table of content</h2> + +""" + +println """ + +<table BORDER=0 CELLSPACING=5 WIDTH="85%" > + +<!-- Begin Groovlet --> +<tr VALIGN=TOP> +<td>Hello World</td> + +<td VALIGN=TOP WIDTH="30%"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP><a href="hello/hello.groovy">Execute</a></td> + +<td WIDTH="30%"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP>Source</td> +</tr> +<!-- End Groovlet --> + + +<!-- Begin Groovlet --> +<tr VALIGN=TOP> +<td>Zoo</td> + +<td VALIGN=TOP WIDTH="30%"><img SRC="images/execute.gif" HSPACE=4 BORDER=0 align=TOP><a href="zoo/zoo.groovy">Execute</a></td> + +<td WIDTH="30%"><img SRC="images/code.gif" HSPACE=4 BORDER=0 height=24 width=24 align=TOP>Source</td> +</tr> +<!-- End Groovlet --> +</table> + +<h2>Note</h2> + +<p>The source code for these examples does not contain all of the +source code that is actually in the example, only the important sections +of code. Code not important to understand the example has been removed +for clarity. +</body> +</html> +""" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/readme.txt ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/readme.txt b/src/main/groovy/webapps/groovlet-examples/readme.txt new file mode 100644 index 0000000..bd57e05 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/readme.txt @@ -0,0 +1,32 @@ +==== + 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. +==== + + +GroovyServlet examples + +[ / ] +Only contains the "index.groovy", "codehaus-style.css" and "readme.txt" files. + +[ /hello ] +Contains a single welcome file named "hello.groovy" showing a simple groovlet. + +[ /zoo ] +The zoo demonstrates a groovy setup of scripts, that are partly <i>hidden</i> +beneath the "WEB-INF/groovy" directory. Note the different package names in the +script files. http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/xml/index.xhtml ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/xml/index.xhtml b/src/main/groovy/webapps/groovlet-examples/xml/index.xhtml new file mode 100644 index 0000000..06c9a17 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/xml/index.xhtml @@ -0,0 +1,58 @@ +<?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. + +--> +<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" --> + +<html xmlns:gsp="http://groovy.codehaus.org/2005/gsp"> + + <head> + <link rel="stylesheet" href="../codehaus-style.css" type="text/css" /> + </head> + + <body> + + Name = ${request.getParameter("name")} <br/> + Name = <gsp:expression>params.get("name")</gsp:expression> + + <hr color="#12334" noshade="noshade" /> + + BEGIN + + <br/> + + <gsp:scriptlet> + <![CDATA[ + 3.times { + ]]> + </gsp:scriptlet> +* Hello World! * + <gsp:scriptlet> + <![CDATA[ } // 3.times ]]> + </gsp:scriptlet> + + <br/> + + END + + </body> + +</html> http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/zoo/HommingbergerGepardenforelle.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/zoo/HommingbergerGepardenforelle.groovy b/src/main/groovy/webapps/groovlet-examples/zoo/HommingbergerGepardenforelle.groovy new file mode 100644 index 0000000..2280e05 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/zoo/HommingbergerGepardenforelle.groovy @@ -0,0 +1,27 @@ +/* + * 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. + */ +package zoo + +class HommingbergerGepardenforelle extends zoo.fish.Trout { + + String saySomething(String something) { + return something; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/zoo/visit.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/zoo/visit.groovy b/src/main/groovy/webapps/groovlet-examples/zoo/visit.groovy new file mode 100644 index 0000000..7c81126 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/zoo/visit.groovy @@ -0,0 +1,37 @@ +/* + * 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. + */ +Animal shark = new zoo.fish.Shark() +Animal trout = new zoo.fish.Trout() +Animal forelle = new zoo.HommingbergerGepardenforelle() + +println """ +<html> + <head> + <title>Groovy Servlet Example - Visiting the zoo</title> + </head> + <body> + <p>Shark<br> + ${shark.saySomething("\"Where is the trout?\"")} + <p>Trout<br> + ${trout.saySomething("Here is the trout!")} + <p>Forelle<br> + ${forelle.saySomething("\"<a href=\"http://www.hommingberger-forelle.de\">There is no spoon.</a>\"")} + </body> +</html> +""" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/groovlet-examples/zoo/zoo.groovy ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/groovlet-examples/zoo/zoo.groovy b/src/main/groovy/webapps/groovlet-examples/zoo/zoo.groovy new file mode 100644 index 0000000..38a4c94 --- /dev/null +++ b/src/main/groovy/webapps/groovlet-examples/zoo/zoo.groovy @@ -0,0 +1,48 @@ +/* + * 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. + */ +println """ +<html> + <head> + <title>Groovy Servlet Example - Visiting the zoo</title> + </head> + <body> + <a href="../"><img src="../images/return.gif" width="24" height="24" border="0"></a><a href="../">Return</a> + <p> +""" + +Animal shark = new zoo.fish.Shark() +Animal trout = new zoo.fish.Trout() +Animal forelle = new zoo.HommingbergerGepardenforelle() + +println """ + <p>Shark<br> + ${shark.saySomething("\"Where is the trout?\"")} + + <p>Trout<br> + ${trout.saySomething("Here is the trout!")} + + <p>Forelle<br> + ${forelle.saySomething("\"<a href=\"http://www.hommingberger-forelle.de\">There is no spoon.</a>\"")} + <!-- http://en.wikipedia.org/wiki/Nigritude_ultramarine --> +""" + +println """ + </body> +</html> +""" http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/gsp-examples/readme.txt ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/gsp-examples/readme.txt b/src/main/groovy/webapps/gsp-examples/readme.txt new file mode 100644 index 0000000..6f197c6 --- /dev/null +++ b/src/main/groovy/webapps/gsp-examples/readme.txt @@ -0,0 +1,20 @@ +==== + 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. +==== + +TODO Second, setup WEB-INF and examples gsp files. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/template-examples/3.times.HelloWorld.html ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/template-examples/3.times.HelloWorld.html b/src/main/groovy/webapps/template-examples/3.times.HelloWorld.html new file mode 100644 index 0000000..d270530 --- /dev/null +++ b/src/main/groovy/webapps/template-examples/3.times.HelloWorld.html @@ -0,0 +1,33 @@ +<!-- + + 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. + +--> +<html> + <body> + + <% 3.times { %> + Hello World! + <% } %> + + <br> + + session id = ${session.id} + + </body> +</html> http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/template-examples/WEB-INF/lib/groovy-all-xyz.jar.placeholder ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/template-examples/WEB-INF/lib/groovy-all-xyz.jar.placeholder b/src/main/groovy/webapps/template-examples/WEB-INF/lib/groovy-all-xyz.jar.placeholder new file mode 100644 index 0000000..f0f8ae5 --- /dev/null +++ b/src/main/groovy/webapps/template-examples/WEB-INF/lib/groovy-all-xyz.jar.placeholder @@ -0,0 +1,18 @@ +/* + * 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. + */ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/template-examples/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/template-examples/WEB-INF/web.xml b/src/main/groovy/webapps/template-examples/WEB-INF/web.xml new file mode 100644 index 0000000..2345235 --- /dev/null +++ b/src/main/groovy/webapps/template-examples/WEB-INF/web.xml @@ -0,0 +1,46 @@ +<!-- + + 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. + +--> +<web-app xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" + version="2.4"> + +<servlet> + <servlet-name>template</servlet-name> + <servlet-class>groovy.servlet.TemplateServlet</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>template</servlet-name> + <url-pattern>*.htm</url-pattern> + </servlet-mapping> + + <servlet-mapping> + <servlet-name>template</servlet-name> + <url-pattern>*.html</url-pattern> + </servlet-mapping> + + <servlet-mapping> + <servlet-name>template</servlet-name> + <url-pattern>*.template</url-pattern> + </servlet-mapping> + +</web-app> http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/template-examples/javasystemproperties.htm ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/template-examples/javasystemproperties.htm b/src/main/groovy/webapps/template-examples/javasystemproperties.htm new file mode 100644 index 0000000..fa1f2c5 --- /dev/null +++ b/src/main/groovy/webapps/template-examples/javasystemproperties.htm @@ -0,0 +1,42 @@ +<!-- + + 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. + +--> +<html> +<head> +<title>System properties</title> +</head> +<body> + +<h1>System properties</h1> +<% keys = System.getProperties().keySet(); + if (keys.isEmpty()) { + out.println('No keys.'); + } + else { + %> +<dl> + <% for (key in keys) { %> + <dt> <b> ${key} </b> </dt> + <dd> <tt> ${System.getProperty(key)} </tt> </dd> + <% } %> +</dl> +<% } %> +</body> +</html> http://git-wip-us.apache.org/repos/asf/groovy-examples/blob/3bd1e181/src/main/groovy/webapps/template-examples/readme.txt ---------------------------------------------------------------------- diff --git a/src/main/groovy/webapps/template-examples/readme.txt b/src/main/groovy/webapps/template-examples/readme.txt new file mode 100644 index 0000000..269ffbd --- /dev/null +++ b/src/main/groovy/webapps/template-examples/readme.txt @@ -0,0 +1,32 @@ +==== + 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. +==== + + +TemplateServlet examples + +[ /readme.txt ] +This readme file. For clarity sake, it does not contain a welcome file and +therefore the servlet container should list all files and subdirectories listed +below. + +[ /3.times.HelloWorld.html ] +Prints three times "Hello World!" and the session id. + +[ /javasystemproperties.htm ] +Lists Java runtime system properties.
