0
|
1
|
|
2 package nabble.view.web.seo;
|
|
3
|
|
4 import fschmidt.util.servlet.JtpContext;
|
|
5 import nabble.view.lib.UrlMappable;
|
|
6 import nabble.model.Init;
|
|
7 import nabble.view.web.more.ForumStart;
|
|
8
|
|
9 import javax.servlet.ServletException;
|
|
10 import javax.servlet.http.HttpServlet;
|
|
11 import javax.servlet.http.HttpServletRequest;
|
|
12 import javax.servlet.http.HttpServletResponse;
|
|
13 import java.io.IOException;
|
|
14 import java.util.Collections;
|
|
15 import java.util.Map;
|
|
16 import java.util.regex.Pattern;
|
|
17
|
|
18
|
|
19 public final class WidgetRedir extends HttpServlet implements UrlMappable {
|
|
20
|
|
21 private static final Pattern URL_PATTERN = Pattern.compile("/free-forum-widget\\.html$");
|
|
22
|
|
23 private static final String WIDGET_REDIR = Init.get("widgetRedir", ForumStart.path("forum"));
|
|
24
|
|
25 private static String path() {
|
|
26 return "/free-forum-widget.html";
|
|
27 }
|
|
28
|
|
29 public Map<String,String[]> getParameterMapFromUrl(HttpServletRequest request,String mappedUrl) {
|
|
30 return Collections.emptyMap();
|
|
31 }
|
|
32
|
|
33 public Pattern getUrlPattern() {
|
|
34 return URL_PATTERN;
|
|
35 }
|
|
36
|
|
37 protected void service(HttpServletRequest request,HttpServletResponse response)
|
|
38 throws ServletException, IOException
|
|
39 {
|
|
40 response.setHeader("Location", WIDGET_REDIR);
|
|
41 response.sendError(HttpServletResponse.SC_MOVED_PERMANENTLY);
|
|
42 }
|
|
43 }
|
|
44
|