fixed README file

changed filter to match url pattern
This commit is contained in:
Joel Juarez 2019-02-15 22:53:52 +01:00
parent 445fee41b3
commit fc88c99537
4 changed files with 8 additions and 15 deletions

View File

@ -1,2 +1,2 @@
FROM tomcat
ADD ./target/javax-servlets-3-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/
ADD ./target/uppercasing-app.war /usr/local/tomcat/webapps/

View File

@ -3,7 +3,8 @@ mvn package
## Run with Tomcat on Docker container:
docker build --tag my-tomcat .
docker run -it --rm -p 8080:8080 my-tomcat
### Relevant Articles:
## Relevant Articles:
- [Java Web Application Without Web.xml]

View File

@ -31,6 +31,7 @@
<spring.version>5.1.3.RELEASE</spring.version>
</properties>
<build>
<finalName>uppercasing-app</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

View File

@ -8,9 +8,8 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
import java.io.PrintWriter;
@WebFilter(servletNames = { "uppercaseServlet" }, filterName = "emptyParamFilter")
@WebFilter(servletNames = { "uppercaseServlet" }, urlPatterns = "/uppercase")
public class EmptyParamFilter implements Filter {
@Override
@ -22,21 +21,13 @@ public class EmptyParamFilter implements Filter {
FilterChain filterChain) throws IOException, ServletException {
String inputString = servletRequest.getParameter("input");
if (inputString == null || inputString.isEmpty()) {
response(servletResponse);
} else {
if (inputString != null && inputString.matches("[A-Za-z0-9]+")) {
filterChain.doFilter(servletRequest, servletResponse);
} else {
servletResponse.getWriter().println("Missing input parameter");
}
}
private void response(ServletResponse response) throws IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Missing input parameter");
}
@Override
public void destroy() {
}