Class FileUploadDownloadServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.apgar.common.lib.ui.widget.fileattachmentwidget.FileUploadDownloadServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class FileUploadDownloadServlet extends javax.servlet.http.HttpServlet
Servlet class responsible for handling the file storage as a hash and retrieving.

This class extends HttpServlet and performs GET and POST calls concerning the file to save it or read it from the upload directory which needs to be specified in the web.xml of your project.

Here is an example of how to define this servlet in your project's web.xml along with the fielUploadDirectory where your files will be stored.

   <servlet>
       <servlet-name>FileUploadDownloadServlet</servlet-name>
       <servlet-class>com.apgar.common.lib.ui.widget.fileattachmentwidget.FileUploadDownloadServlet</servlet-class>
       <init-param>
           <param-name>fileUploadDirectory</param-name>
           <param-value>C:/apps/workspaces/YourProject/ebxHome/uploadDir</param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet-mapping>
       <servlet-name>FileUploadDownloadServlet</servlet-name>
       <url-pattern>/FileUploadDownloadServlet</url-pattern>
   </servlet-mapping>
 
Author:
APGAR Consulting
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doGet(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse)
     
    protected void
    doPost(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse)
     
    void
    init(javax.servlet.ServletConfig config)
     
    void
    setFileUploadDirectory(String fileUploadDirectory)
    Sets the fileUploadDirectory variable which corresponds to the String path of the file directory in your project.

    Methods inherited from class javax.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service

    Methods inherited from class javax.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FileUploadDownloadServlet

      public FileUploadDownloadServlet()
  • Method Details

    • init

      public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
      Specified by:
      init in interface javax.servlet.Servlet
      Overrides:
      init in class javax.servlet.GenericServlet
      Throws:
      javax.servlet.ServletException
    • doPost

      protected void doPost(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse) throws javax.servlet.ServletException, IOException
      Overrides:
      doPost in class javax.servlet.http.HttpServlet
      Throws:
      javax.servlet.ServletException
      IOException
    • doGet

      protected void doGet(javax.servlet.http.HttpServletRequest pRequest, javax.servlet.http.HttpServletResponse pResponse) throws javax.servlet.ServletException, IOException
      Overrides:
      doGet in class javax.servlet.http.HttpServlet
      Throws:
      javax.servlet.ServletException
      IOException
    • setFileUploadDirectory

      public void setFileUploadDirectory(String fileUploadDirectory)
      Sets the fileUploadDirectory variable which corresponds to the String path of the file directory in your project.
      Parameters:
      fileUploadDirectory - String