1
2
3
4
5 package net.sf.wfnm.web;
6
7 import java.io.Serializable;
8
9 import javax.servlet.http.HttpServletRequest;
10
11
12 /***
13 * Implements the function that calculate the URL as the name of the page.
14 *
15 * @author <a href="mailto:malbari@users.sourceforge.net">Maurizio Albari</a>
16 * @version 1.0.6
17 */
18 public class PageUrlCalculator implements UrlCalculator, Serializable {
19 /***
20 * Creates a new PageUrlCalculator object.
21 */
22 public PageUrlCalculator() {
23 super();
24 }
25
26 /***
27 * Calculates the URl of the page given the HttpServletRequest
28 *
29 * @param request the HttpServletRequest
30 *
31 * @return the calculated URL
32 */
33 public String calculateUrl(HttpServletRequest request) {
34 String reqUri = request.getRequestURI();
35 String ctPath = request.getContextPath();
36 String url = reqUri.startsWith(ctPath) ? reqUri.substring(ctPath.length()) : reqUri;
37
38 return url;
39 }
40 }