View Javadoc

1   package com.atlassian.plugin.servlet;
2   
3   import com.atlassian.plugin.Plugin;
4   import com.atlassian.plugin.elements.ResourceLocation;
5   
6   import javax.servlet.http.HttpServletRequest;
7   import javax.servlet.http.HttpServletResponse;
8   import javax.servlet.ServletException;
9   import java.io.IOException;
10  
11  public class DownloadableWebResource extends AbstractDownloadableResource
12  {
13      public DownloadableWebResource(BaseFileServerServlet servlet, Plugin plugin, ResourceLocation resourceDescriptor, String extraPath)
14      {
15          super(servlet, plugin, resourceDescriptor, extraPath);
16      }
17  
18      public void serveResource(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException
19      {
20          try
21          {
22              httpServletResponse.setContentType(getContentType()); // this will be used if content-type is not set by the forward handler, e.g. for webapp content in Tomcat
23              httpServletRequest.getRequestDispatcher(getLocation()).forward(httpServletRequest, httpServletResponse);
24          }
25          catch (ServletException e)
26          {
27              e.printStackTrace();
28              throw new IOException(e.getMessage());
29          }
30      }
31  }