1
14
15 package com.liferay.taglib.util;
16
17 import com.liferay.portal.kernel.util.StringPool;
18 import com.liferay.portal.kernel.util.Time;
19 import com.liferay.portal.kernel.util.Validator;
20 import com.liferay.portal.kernel.webcache.WebCacheItem;
21 import com.liferay.portal.kernel.webcache.WebCachePoolUtil;
22
23 import javax.servlet.jsp.JspException;
24 import javax.servlet.jsp.tagext.TagSupport;
25
26
31 public class GetUrlTag extends TagSupport {
32
33 public int doEndTag() throws JspException {
34 try {
35 WebCacheItem wci = new GetUrlWebCacheItem(_url, _expires);
36
37 String content = (String)WebCachePoolUtil.get(
38 GetUrlTag.class.getName() + StringPool.PERIOD + _url, wci);
39
40 if (Validator.isNotNull(_var)) {
41 pageContext.setAttribute(_var, content);
42 }
43 else {
44 pageContext.getOut().print(content);
45 }
46
47 return EVAL_PAGE;
48 }
49 catch (Exception e) {
50 throw new JspException(e);
51 }
52 }
53
54 public void setUrl(String url) {
55 _url = url;
56 }
57
58 public void setExpires(long expires) {
59 _expires = expires;
60 }
61
62 public void setVar(String var) {
63 _var = var;
64 }
65
66 private String _url;
67 private long _expires = Time.WEEK;
68 private String _var;
69
70 }