Kawai Wiki

Rev

Rev 93 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 93 Rev 194
Line 2... Line 2...
2
2
3
import java.util.Map;
3
import java.util.Map;
-
 
4
4
5
5
import javax.servlet.http.HttpServletRequest;
6
import javax.servlet.http.HttpServletRequest;
6
import javax.servlet.jsp.JspException;
7
import javax.servlet.jsp.JspException;
7
import javax.servlet.jsp.PageContext;
8
import javax.servlet.jsp.PageContext;
8
9
-
 
10
/**
-
 
11
 * KCode class ContextPath.
-
 
12
 *
-
 
13
 * @author Sergio Oliveira
-
 
14
 *
-
 
15
 */
9
public class ContextPath implements KCode {
16
public class ContextPath implements KCode {
10
       
-
 
11
        @Override
-
 
12
        public String getTag() {
-
 
13
                return "contextPath";
-
 
14
        }
-
 
15
       
-
 
16
        @Override
-
 
17
        public boolean hasBody() {
-
 
18
                return false;
-
 
19
        }
-
 
20
       
-
 
21
        @Override
-
 
22
        public String process(PageContext pageContext, Map<String, String> attributes, String body) throws JspException {
-
 
23
                if (body != null) throw new JspException("contextPath tag cannot have a body!");
-
 
24
                HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
-
 
25
                return req.getContextPath();
-
 
26
        }
-
 
27
}
17
-
 
18
    /**
-
 
19
     * {@inheritDoc}.
-
 
20
     */
-
 
21
    @Override
-
 
22
    public String getTag() {
-
 
23
        return "contextPath";
-
 
24
    }
-
 
25
-
 
26
    /**
-
 
27
     * {@inheritDoc}.
-
 
28
     */
-
 
29
    @Override
-
 
30
    public boolean hasBody() {
-
 
31
        return false;
-
 
32
    }
-
 
33
-
 
34
    /**
-
 
35
     * {@inheritDoc}.
-
 
36
     */
-
 
37
    @Override
-
 
38
    public String process(PageContext pageContext, Map<String, String> attributes, String body) throws JspException {
-
 
39
        if (body != null) throw new JspException("contextPath tag cannot have a body!");
-
 
40
        HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
-
 
41
        return req.getContextPath();
-
 
42
    }
-
 
43
}