Kawai Wiki

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.kawai.tag.kcode;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;

public class ContextPath implements KCode {
       
        @Override
        public String getTag() {
                return "contextPath";
        }
       
        @Override
        public boolean hasBody() {
                return false;
        }
       
        @Override
        public String process(PageContext pageContext, Map<String, String> attributes, String body) throws JspException {
                if (body != null) throw new JspException("contextPath tag cannot have a body!");
                HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
                return req.getContextPath();
        }
}