diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c771039 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!/target/struts-blank.war diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07827cc --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +target/ +.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b1affcd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM docker.io/tomcat:9.0.87-jre21-temurin-jammy +COPY target/struts-blank.war /usr/local/tomcat/webapps/ + diff --git a/README.md b/README.md index 9aed515..3f6921d 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ How to run - Run the following command. ```bash -./scripts/deploy-local.sh +./scripts/start.sh ``` - Open the following URL with your browser. diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..a9f0052 --- /dev/null +++ b/mise.toml @@ -0,0 +1,3 @@ +[tools] +maven = '3.9.9' +java = 'zulu-21.40.17' diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ded6e57 --- /dev/null +++ b/pom.xml @@ -0,0 +1,53 @@ + + + + + + 4.0.0 + org.apache.struts + struts-blank + war + Struts Apps - Blank + 1.0.0 + + + + org.apache.struts + struts-taglib + 1.3.10 + + + javax.servlet + servlet-api + 2.3 + provided + + + + + ${project.artifactId} + + + org.apache.maven.plugins + maven-war-plugin + 3.4.0 + + + + diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100755 index 0000000..1c33384 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -eu + +SCRIPT_DIR=$(realpath "$(dirname $BASH_SOURCE)") +PROJECT_BASE_DIR=$(realpath "$SCRIPT_DIR/..") + +APP_NAME=blank +CONTAINER_NAME=springing-struts1-$APP_NAME +DOCKER=$( (command -v podman &> /dev/null) && echo podman || echo docker ) + +main() { + build && start +} + +build() { + mvn clean package -U +} + +start() { + $DOCKER build -t $CONTAINER_NAME . \ + && $DOCKER rm -f $CONTAINER_NAME \ + && $DOCKER run -d \ + -p 8080:8080 \ + -p 5005:5005 \ + --name $CONTAINER_NAME \ + --env DEBUG_PORT=5005 \ + $CONTAINER_NAME +} + +(cd "$PROJECT_BASE_DIR" \ + && eval "$(mise env)" \ + && main +) diff --git a/src/main/resources/MessageResources.properties b/src/main/resources/MessageResources.properties new file mode 100644 index 0000000..a48defe --- /dev/null +++ b/src/main/resources/MessageResources.properties @@ -0,0 +1,44 @@ +# 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. + +# -- standard errors -- +errors.header= +# -- validator -- +errors.invalid={0} is invalid. +errors.maxlength={0} can not be greater than {1} characters. +errors.minlength={0} can not be less than {1} characters. +errors.range={0} is not in the range {1} through {2}. +errors.required={0} is required. +errors.byte={0} must be an byte. +errors.date={0} is not a date. +errors.double={0} must be an double. +errors.float={0} must be an float. +errors.integer={0} must be an integer. +errors.long={0} must be an long. +errors.short={0} must be an short. +errors.creditcard={0} is not a valid credit card number. +errors.email={0} is an invalid e-mail address. +# -- other -- +errors.cancel=Operation cancelled. +errors.detail={0} +errors.general=The process did not complete. Details should follow. +errors.token=Request could not be completed. Operation is not in sequence. +# -- welcome -- +welcome.title=Struts Blank Application +welcome.heading=Welcome! +welcome.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, restart your container, and you are on your way! (You can find the MessageResources.properties file with this message in the /WEB-INF/src folder.) diff --git a/src/main/webapp/WEB-INF/struts-config.xml b/src/main/webapp/WEB-INF/struts-config.xml new file mode 100644 index 0000000..513c0fa --- /dev/null +++ b/src/main/webapp/WEB-INF/struts-config.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/validation.xml b/src/main/webapp/WEB-INF/validation.xml new file mode 100644 index 0000000..ca6645f --- /dev/null +++ b/src/main/webapp/WEB-INF/validation.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + +
+ + + + + + + mask + ^[0-9a-zA-Z]*$ + + +
+ +
+ + + + + + postalCode + ^[0-9a-zA-Z]*$ + + + +
+ + + + + + + mask + ^[0-9a-zA-Z]*$ + + +
+ +
+ +
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..62c1df2 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,50 @@ + + + + + + + Struts Blank Application + + + + action + org.apache.struts.action.ActionServlet + + config + /WEB-INF/struts-config.xml + + 2 + + + + + + action + *.do + + + + + + index.jsp + + + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..07da6b5 --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,25 @@ +<%-- + 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. +--%> +<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> + + +<%-- + +Redirect default requests to Welcome global ActionForward. +By using a redirect, the user-agent will change address to match the path of our Welcome ActionForward. + +--%> diff --git a/src/main/webapp/pages/Welcome.jsp b/src/main/webapp/pages/Welcome.jsp new file mode 100644 index 0000000..b83e322 --- /dev/null +++ b/src/main/webapp/pages/Welcome.jsp @@ -0,0 +1,39 @@ +<%-- + 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. +--%> +<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> +<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> +<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> + + + +<bean:message key="welcome.title"/> + + + + + + + ERROR: Application resources not loaded -- check servlet container + logs for error messages. + + + +

+

+ + +