1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }