diff --git a/enterprise-patterns/intercepting-filter-pattern/pom.xml b/enterprise-patterns/intercepting-filter-pattern/pom.xml new file mode 100644 index 0000000000..ffe597a813 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + intercepting-filter-pattern + war + + + enterprise-patterns-parent + com.baeldung.enterprise.patterns + 1.0.0-SNAPSHOT + + + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + org.slf4j + slf4j-api + 1.7.21 + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.eclipse.jetty + jetty-maven-plugin + 9.3.11.v20160721 + + + /intercepting-filter + + + + + + diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/FrontControllerServlet.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/FrontControllerServlet.java new file mode 100644 index 0000000000..728caca27e --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/FrontControllerServlet.java @@ -0,0 +1,55 @@ +package com.baeldung.enterprise.patterns.front.controller; + +import com.baeldung.enterprise.patterns.front.controller.commands.FrontCommand; +import com.baeldung.enterprise.patterns.front.controller.commands.UnknownCommand; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet(name = "front-controller", urlPatterns = "/") +public class FrontControllerServlet extends HttpServlet { + @Override + protected void doGet( + HttpServletRequest request, + HttpServletResponse response + ) throws ServletException, IOException { + doCommand(request, response); + } + + @Override + protected void doPost( + HttpServletRequest request, + HttpServletResponse response + ) throws ServletException, IOException { + doCommand(request, response); + } + + private void doCommand( + HttpServletRequest request, + HttpServletResponse response + ) throws ServletException, IOException { + FrontCommand command = getCommand(request); + command.init(request, response); + command.process(); + } + + private FrontCommand getCommand(HttpServletRequest request) { + try { + Class type = Class.forName( + String.format( + "com.baeldung.enterprise.patterns.front.controller.commands.%sCommand", + request.getParameter("command") + ) + ); + return (FrontCommand) type + .asSubclass(FrontCommand.class) + .newInstance(); + } catch (Exception e) { + return new UnknownCommand(); + } + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/FrontCommand.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/FrontCommand.java new file mode 100644 index 0000000000..370127b7f7 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/FrontCommand.java @@ -0,0 +1,43 @@ +package com.baeldung.enterprise.patterns.front.controller.commands; + +import com.baeldung.enterprise.patterns.front.controller.filters.FilterManager; +import com.baeldung.enterprise.patterns.front.controller.filters.OnIntercept; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public abstract class FrontCommand implements OnIntercept { + protected HttpServletRequest request; + protected HttpServletResponse response; + private boolean intercept; + + public FrontCommand() { + } + + public void init(HttpServletRequest request, HttpServletResponse response) { + this.request = request; + this.response = response; + } + + public void process() throws ServletException, IOException { + FilterManager.process(request, response, this); + } + + public void forward(String target) throws ServletException, IOException { + if (intercept) { + return; + } + String path = String.format("/WEB-INF/jsp/%s.jsp", target); + RequestDispatcher dispatcher = request.getServletContext() + .getRequestDispatcher(path); + dispatcher.forward(request, response); + } + + @Override + public void intercept() { + intercept = true; + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/LoginCommand.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/LoginCommand.java new file mode 100644 index 0000000000..719605108e --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/LoginCommand.java @@ -0,0 +1,20 @@ +package com.baeldung.enterprise.patterns.front.controller.commands; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpSession; +import java.io.IOException; + +public class LoginCommand extends FrontCommand { + @Override + public void process() throws ServletException, IOException { + if (request.getMethod().equals("GET")) { + request.setAttribute("redirect", request.getRequestURL() + .append("?").append(request.getQueryString()).toString()); + forward("login"); + } else { + HttpSession session = request.getSession(true); + session.setAttribute("username", request.getParameter("username")); + response.sendRedirect(request.getParameter("redirect")); + } + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/SearchCommand.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/SearchCommand.java new file mode 100644 index 0000000000..93dac4b363 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/SearchCommand.java @@ -0,0 +1,22 @@ +package com.baeldung.enterprise.patterns.front.controller.commands; + +import com.baeldung.enterprise.patterns.front.controller.data.Book; +import com.baeldung.enterprise.patterns.front.controller.data.BookshelfImpl; + +import javax.servlet.ServletException; +import java.io.IOException; + +public class SearchCommand extends FrontCommand { + @Override + public void process() throws ServletException, IOException { + super.process(); + Book book = new BookshelfImpl().getInstance() + .findByTitle(request.getParameter("title")); + if (book != null) { + request.setAttribute("book", book); + forward("book-found"); + } else { + forward("book-notfound"); + } + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/UnknownCommand.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/UnknownCommand.java new file mode 100644 index 0000000000..90103c8f42 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/commands/UnknownCommand.java @@ -0,0 +1,11 @@ +package com.baeldung.enterprise.patterns.front.controller.commands; + +import javax.servlet.ServletException; +import java.io.IOException; + +public class UnknownCommand extends FrontCommand { + @Override + public void process() throws ServletException, IOException { + forward("unknown"); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/Book.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/Book.java new file mode 100644 index 0000000000..abadcc0d76 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/Book.java @@ -0,0 +1,15 @@ +package com.baeldung.enterprise.patterns.front.controller.data; + +public interface Book { + String getAuthor(); + + void setAuthor(String author); + + String getTitle(); + + void setTitle(String title); + + Double getPrice(); + + void setPrice(Double price); +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/BookImpl.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/BookImpl.java new file mode 100644 index 0000000000..b270bc7985 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/BookImpl.java @@ -0,0 +1,46 @@ +package com.baeldung.enterprise.patterns.front.controller.data; + +public class BookImpl implements Book { + private String author; + private String title; + private Double price; + + public BookImpl() { + } + + public BookImpl(String author, String title, Double price) { + this.author = author; + this.title = title; + this.price = price; + } + + @Override + public String getAuthor() { + return author; + } + + @Override + public void setAuthor(String author) { + this.author = author; + } + + @Override + public String getTitle() { + return title; + } + + @Override + public void setTitle(String title) { + this.title = title; + } + + @Override + public Double getPrice() { + return price; + } + + @Override + public void setPrice(Double price) { + this.price = price; + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/Bookshelf.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/Bookshelf.java new file mode 100644 index 0000000000..8def45cb69 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/Bookshelf.java @@ -0,0 +1,16 @@ +package com.baeldung.enterprise.patterns.front.controller.data; + +public interface Bookshelf { + + default void init() { + add(new BookImpl("Wilson, Robert Anton & Shea, Robert", "Illuminati", 9.99)); + add(new BookImpl("Fowler, Martin", "Patterns of Enterprise Application Architecture", 27.88)); + add(new BookImpl("Unknown", "Something about German Umlauts (äüö) and ß", 5.49)); + } + + Bookshelf getInstance(); + + boolean add(E book); + + Book findByTitle(String title); +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/BookshelfImpl.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/BookshelfImpl.java new file mode 100644 index 0000000000..3862418857 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/BookshelfImpl.java @@ -0,0 +1,24 @@ +package com.baeldung.enterprise.patterns.front.controller.data; + +import java.util.ArrayList; + +public class BookshelfImpl extends ArrayList implements Bookshelf { + private static Bookshelf INSTANCE; + + @Override + public Bookshelf getInstance() { + if (INSTANCE == null) { + INSTANCE = new BookshelfImpl(); + INSTANCE.init(); + } + return INSTANCE; + } + + @Override + public Book findByTitle(String title) { + return this.stream() + .filter(book -> book.getTitle().toLowerCase().contains(title.toLowerCase())) + .findFirst() + .orElse(null); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuditFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuditFilter.java new file mode 100644 index 0000000000..d24c0a94b3 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuditFilter.java @@ -0,0 +1,25 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.io.IOException; + +public class AuditFilter extends BaseFilter { + @Override + public void doFilter( + ServletRequest request, + ServletResponse response, + FilterChain chain + ) throws IOException, ServletException { + HttpServletRequest httpServletRequest = (HttpServletRequest) request; + HttpSession session = httpServletRequest.getSession(false); + if (session != null && session.getAttribute("username") != null) { + request.setAttribute("username", session.getAttribute("username")); + } + chain.doFilter(request, response); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuthenticationFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuthenticationFilter.java new file mode 100644 index 0000000000..66f9887980 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/AuthenticationFilter.java @@ -0,0 +1,40 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import com.baeldung.enterprise.patterns.front.controller.commands.FrontCommand; +import com.baeldung.enterprise.patterns.front.controller.commands.LoginCommand; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.io.IOException; + +public class AuthenticationFilter extends BaseFilter { + private OnIntercept callback; + + public AuthenticationFilter(OnIntercept callback) { + this.callback = callback; + } + + @Override + public void doFilter( + ServletRequest request, + ServletResponse response, + FilterChain chain + ) throws IOException, ServletException { + HttpServletRequest httpServletRequest = (HttpServletRequest) request; + HttpServletResponse httpServletResponse = (HttpServletResponse) response; + HttpSession session = httpServletRequest.getSession(false); + if (session == null || session.getAttribute("username") == null) { + FrontCommand command = new LoginCommand(); + command.init(httpServletRequest, httpServletResponse); + command.process(); + callback.intercept(); + } else { + chain.doFilter(request, response); + } + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/BaseFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/BaseFilter.java new file mode 100644 index 0000000000..81b5027187 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/BaseFilter.java @@ -0,0 +1,25 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.Filter; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; + +public abstract class BaseFilter implements Filter { + private static final Logger log = LoggerFactory.getLogger(BaseFilter.class); + + protected FilterConfig filterConfig; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + log.info("Initialize filter: {}", getClass().getSimpleName()); + this.filterConfig = filterConfig; + } + + @Override + public void destroy() { + log.info("Destroy filter: {}", getClass().getSimpleName()); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/EncodingFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/EncodingFilter.java new file mode 100644 index 0000000000..d36e204dd5 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/EncodingFilter.java @@ -0,0 +1,30 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import java.io.IOException; + +@WebFilter(servletNames = "front-controller") +public class EncodingFilter extends BaseFilter { + private String encoding; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + super.init(filterConfig); + this.encoding = filterConfig.getInitParameter("encoding"); + } + + @Override + public void doFilter( + ServletRequest request, + ServletResponse response, + FilterChain chain + ) throws IOException, ServletException { + String encoding = request.getParameter("encoding"); + if (encoding == null) { + encoding = this.encoding; + } + response.setCharacterEncoding(encoding); + chain.doFilter(request, response); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/FilterChainImpl.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/FilterChainImpl.java new file mode 100644 index 0000000000..dd92759e8b --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/FilterChainImpl.java @@ -0,0 +1,28 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import javax.servlet.Filter; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; + +public class FilterChainImpl implements javax.servlet.FilterChain { + private Iterator filters; + + public FilterChainImpl(Filter... filters) { + this.filters = Arrays.asList(filters).iterator(); + } + + @Override + public void doFilter( + ServletRequest request, + ServletResponse response + ) throws IOException, ServletException { + if (filters.hasNext()) { + Filter filter = filters.next(); + filter.doFilter(request, response, this); + } + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/FilterManager.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/FilterManager.java new file mode 100644 index 0000000000..efa8511f2a --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/FilterManager.java @@ -0,0 +1,21 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class FilterManager { + public static void process( + HttpServletRequest request, + HttpServletResponse response, + OnIntercept callback + ) throws ServletException, IOException { + FilterChain filterChain = new FilterChainImpl( + new AuthenticationFilter(callback), + new AuditFilter() + ); + filterChain.doFilter(request, response); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/LoggingFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/LoggingFilter.java new file mode 100644 index 0000000000..089a7807cf --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/LoggingFilter.java @@ -0,0 +1,39 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +@WebFilter(servletNames = "front-controller") +public class LoggingFilter extends BaseFilter { + private static final Logger log = LoggerFactory.getLogger(LoggingFilter.class); + + @Override + public void doFilter( + ServletRequest request, + ServletResponse response, + FilterChain chain + ) throws IOException, ServletException { + chain.doFilter(request, response); + HttpServletRequest httpServletRequest = (HttpServletRequest) request; + String username = (String) httpServletRequest.getAttribute("username"); + if (username != null && username.length() > 0) { + username = username.concat("@"); + } else { + username = ""; + } + String intro = "Request"; + if (username.length() > 0) { + intro = "Authenticated request"; + } + log.info("{} from '{}{}': {}?{}", intro, username, request.getRemoteAddr(), + httpServletRequest.getRequestURI(), request.getParameterMap()); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/OnIntercept.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/OnIntercept.java new file mode 100644 index 0000000000..54da744e78 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/OnIntercept.java @@ -0,0 +1,5 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +public interface OnIntercept { + void intercept(); +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/VisitorCounterFilter.java b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/VisitorCounterFilter.java new file mode 100644 index 0000000000..0ae7cd73fd --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/filters/VisitorCounterFilter.java @@ -0,0 +1,23 @@ +package com.baeldung.enterprise.patterns.front.controller.filters; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; +import java.io.IOException; + +@WebFilter(servletNames = "front-controller") +public class VisitorCounterFilter extends BaseFilter { + private int counter; + + @Override + public void doFilter( + ServletRequest request, + ServletResponse response, + FilterChain chain + ) throws IOException, ServletException { + request.setAttribute("counter", ++counter); + chain.doFilter(request, response); + } +} diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/book-found.jsp b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/book-found.jsp new file mode 100644 index 0000000000..36f94b0933 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/book-found.jsp @@ -0,0 +1,13 @@ + + + + Bookshelf: Title found + + +

Our Bookshelf contains this title:

+

${book.getTitle()}

+

Author: ${book.getAuthor()}

+ + <%@include file="visitor-counter.jsp"%> + + diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/book-notfound.jsp b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/book-notfound.jsp new file mode 100644 index 0000000000..02d1307e00 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/book-notfound.jsp @@ -0,0 +1,11 @@ + + + + Bookshelf: Title not found + + +

Our Bookshelf doesn't contains this title:

+

${param.get("title")}

+ <%@include file="visitor-counter.jsp"%> + + diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/login.jsp b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/login.jsp new file mode 100644 index 0000000000..a1609ecaff --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/login.jsp @@ -0,0 +1,15 @@ + + + + Bookshelf: Login + + +

Please input a username:

+

Login

+
+ + + +
+ + diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/unknown.jsp b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/unknown.jsp new file mode 100644 index 0000000000..010cb7ffb4 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/unknown.jsp @@ -0,0 +1,10 @@ + + + + Bookshelf: Command unknown + + +

Sorry, this command is not known!

+ <%@include file="visitor-counter.jsp"%> + + diff --git a/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/visitor-counter.jsp b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/visitor-counter.jsp new file mode 100644 index 0000000000..7dc1d78196 --- /dev/null +++ b/enterprise-patterns/intercepting-filter-pattern/src/main/webapp/WEB-INF/jsp/visitor-counter.jsp @@ -0,0 +1,2 @@ +
+

You are visitor #${counter}!