Skip to content
Snippets Groups Projects
Commit c494b0dd authored by Tim Levett's avatar Tim Levett
Browse files

Merge branch 'multimodule_project_go' into 'master'

MUMMNG-2046 : Split into multimodule project so we can overwrite the inherited 404 and 500 page

myuw-root-jar is a module that will generate a jar that has a single class for tomcat. This class just redirects 404's to `/404.html` and 500 and above to `500.html`. This will be placed in tomcat's classpath.

myuw-root-war is the ROOT.war file that has those html files.

See merge request !2
parents b9acf5cb 6bb5a8a3
No related branches found
No related tags found
No related merge requests found
Showing with 149 additions and 24 deletions
target
.settings
.project
.classpath
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>edu.wisc.my.app.root</groupId>
<artifactId>root-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>myuw-error-valve</artifactId>
<packaging>jar</packaging>
<name>MyUW ROOT lib</name>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.65</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>code.doit-uw-releases</id>
<url>https://code.doit.wisc.edu/maven/content/repositories/uw-releases/</url>
</repository>
</repositories>
<build>
<finalName>myuw-error-valve</finalName>
</build>
</project>
package edu.wisc.my.root;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.util.Scanner;
import org.apache.catalina.Valve;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.valves.Constants;
import org.apache.catalina.valves.ErrorReportValve;
import org.apache.tomcat.util.res.StringManager;
public class MyUWErrorValve extends ErrorReportValve implements Valve {
private static String ERROR_PAGE_LOCATION="/500.html";
private static String MISSING_PAGE_LOCATION="/404.html";
@Override
protected void report(Request request, Response response, Throwable throwable) {
int statusCode = response.getStatus();
// Do nothing on a 1xx, 2xx and 3xx status
// Do nothing if anything has been written already
// Do nothing if the response hasn't been explicitly marked as in error
// and that error has not been reported.
if (statusCode < 400 || response.getContentWritten() > 0 || !response.setErrorReported()) {
return;
}
try {
if(statusCode > 400 && statusCode < 500)
response.sendRedirect(MISSING_PAGE_LOCATION);
else
response.sendRedirect(ERROR_PAGE_LOCATION);
} catch (IOException e) {
super.report(request, response, throwable);
}
}
}
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>edu.wisc.my.app.root</groupId>
<artifactId>root-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ROOT</artifactId>
<packaging>war</packaging>
<name>MyUW ROOT webapp</name>
<url>git@git.doit.wisc.edu:myuw/my-root.git</url>
<repositories>
<repository>
<id>code.doit-uw-releases</id>
<url>https://code.doit.wisc.edu/maven/content/repositories/uw-releases/</url>
</repository>
</repositories>
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.0.M2</version>
<configuration>
<webApp>
<baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection">
<resourcesAsCSV>src/main/webapp,${webapp.target.directory}</resourcesAsCSV>
</baseResource>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -99,7 +99,7 @@
<div id="row">
<div class="col-xs-12 header">
<div class="col-xs-4 col-sm-4 photo-div">
<img src="main_logo_w_all.png" class="crest">
<img src="/main_logo_w_all.png" class="crest">
</div>
<div class="col-xs-4 outage-title">
<h1>Page Not Found</h1>
......
......@@ -99,7 +99,7 @@
<div id="row">
<div class="col-xs-12 header">
<div class="col-xs-4 col-sm-4 photo-div">
<img src="main_logo_w_all.png" class="crest">
<img src="/main_logo_w_all.png" class="crest">
</div>
<div class="col-xs-4 outage-title">
<h1>Server Error</h1>
......
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>MyUW Root</display-name>
<error-page>
<error-code>500</error-code>
<location>/500.html</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/404.html</location>
</error-page>
</web-app>
myuw-root-webapp/src/main/webapp/favicon.ico

1.37 KiB

myuw-root-webapp/src/main/webapp/main_logo_w_all.png

8.38 KiB

......@@ -9,34 +9,21 @@
<modelVersion>4.0.0</modelVersion>
<groupId>edu.wisc.my.app.root</groupId>
<artifactId>ROOT</artifactId>
<packaging>war</packaging>
<artifactId>root-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>MyUW ROOT webapp</name>
<name>MyUW ROOT parent</name>
<url>git@git.doit.wisc.edu:myuw/my-root.git</url>
<modules>
<module>myuw-error-valve</module>
<module>myuw-root-webapp</module>
</modules>
<repositories>
<repository>
<id>code.doit-uw-releases</id>
<url>https://code.doit.wisc.edu/maven/content/repositories/uw-releases/</url>
</repository>
</repositories>
<build>
<finalName>ROOT</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.0.M2</version>
<configuration>
<webApp>
<baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection">
<resourcesAsCSV>src/main/webapp,${webapp.target.directory}</resourcesAsCSV>
</baseResource>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
</project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment