Kawai Wiki

Rev

Go to most recent revision | Details | 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
 
5
import javax.servlet.http.HttpServletRequest;
6
import javax.servlet.jsp.JspException;
7
import javax.servlet.jsp.PageContext;
8
 
9
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
}