1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.portal.kernel.servlet.StringServletResponse;
18  import com.liferay.taglib.util.IncludeTag;
19  
20  import javax.servlet.RequestDispatcher;
21  import javax.servlet.ServletContext;
22  import javax.servlet.http.HttpServletRequest;
23  import javax.servlet.http.HttpServletResponse;
24  import javax.servlet.jsp.JspException;
25  
26  /**
27   * <a href="WebDAVTag.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Jorge Ferrer
30   * @author Brian Wing Shun Chan
31   */
32  public class WebDAVTag extends IncludeTag {
33  
34      public static void doTag(
35              String path, ServletContext servletContext,
36              HttpServletRequest request, HttpServletResponse response)
37          throws Exception {
38  
39          doTag(_PAGE, path, servletContext, request, response);
40      }
41  
42      public static void doTag(
43              String page, String path, ServletContext servletContext,
44              HttpServletRequest request, HttpServletResponse response)
45          throws Exception {
46  
47          request.setAttribute("liferay-ui:webdav:path", path);
48  
49          RequestDispatcher requestDispatcher =
50              servletContext.getRequestDispatcher(page);
51  
52          requestDispatcher.include(request, response);
53      }
54  
55      public int doEndTag() throws JspException {
56          try {
57              ServletContext servletContext = getServletContext();
58              HttpServletRequest request = getServletRequest();
59              StringServletResponse stringResponse = getServletResponse();
60  
61              doTag(getPage(), _path, servletContext, request, stringResponse);
62  
63              pageContext.getOut().print(stringResponse.getString());
64  
65              return EVAL_PAGE;
66          }
67          catch (Exception e) {
68              throw new JspException(e);
69          }
70      }
71  
72      public void setPath(String path) {
73          _path = path;
74      }
75  
76      protected String getDefaultPage() {
77          return _PAGE;
78      }
79  
80      private static final String _PAGE = "/html/taglib/ui/webdav/page.jsp";
81  
82      private String _path;
83  
84  }