Kawai Wiki

Rev

Rev 93 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
93 soliveira 1
package org.kawai.tag.kcode;
2
 
3
import java.util.Map;
4
 
194 helio.frota 5
 
93 soliveira 6
import javax.servlet.http.HttpServletRequest;
7
import javax.servlet.jsp.JspException;
8
import javax.servlet.jsp.PageContext;
9
 
194 helio.frota 10
/**
11
 * KCode class ContextPath.
12
 *
13
 * @author Sergio Oliveira
14
 *
15
 */
93 soliveira 16
public class ContextPath implements KCode {
194 helio.frota 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
}