Class GetServiceFileServlet

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
    Direct Known Subclasses:
    GetServiceFileSecureServlet

    public class GetServiceFileServlet
    extends javax.servlet.http.HttpServlet
    Servlet for getting files from the host. A bit insecure ;)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String FILE  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected String createFileUrl​(javax.servlet.http.HttpServletRequest request, File f)
      Create the url to the file
      protected void doGet​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handles the HTTP GET method.
      protected void doPost​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Handles the HTTP POST method.
      protected File getCorrectedFile​(String fileString)
      Get the corrected File (relative to jvm or absolute)
      String getServletInfo()
      Returns a short description of the servlet.
      void init​(javax.servlet.ServletConfig config)  
      protected void processRequest​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Processes requests for both HTTP GET and POST methods.
      protected void writeErrorMessage​(javax.servlet.http.HttpServletResponse response, String message)
      Write a html page as error
      protected void writeFile​(javax.servlet.http.HttpServletResponse response, File file)
      write a file to the output
      protected void writeFileNotFoundMessage​(javax.servlet.http.HttpServletResponse response, String fileString)
      Write a file not found error message
      protected void writeFileToHtml​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, File file)
      Write a link to the file in html
      • 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, getServletName, init, log, log
    • Constructor Detail

      • GetServiceFileServlet

        public GetServiceFileServlet()
    • Method Detail

      • 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
      • processRequest

        protected void processRequest​(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response)
                               throws javax.servlet.ServletException,
                                      IOException
        Processes requests for both HTTP GET and POST methods.
        Parameters:
        request - servlet request
        response - servlet response
        Throws:
        javax.servlet.ServletException - if a servlet-specific error occurs
        IOException - if an I/O error occurs
      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws javax.servlet.ServletException,
                             IOException
        Handles the HTTP GET method.
        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Parameters:
        request - servlet request
        response - servlet response
        Throws:
        javax.servlet.ServletException - if a servlet-specific error occurs
        IOException - if an I/O error occurs
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws javax.servlet.ServletException,
                              IOException
        Handles the HTTP POST method.
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Parameters:
        request - servlet request
        response - servlet response
        Throws:
        javax.servlet.ServletException - if a servlet-specific error occurs
        IOException - if an I/O error occurs
      • getServletInfo

        public String getServletInfo()
        Returns a short description of the servlet.
        Specified by:
        getServletInfo in interface javax.servlet.Servlet
        Overrides:
        getServletInfo in class javax.servlet.GenericServlet
        Returns:
        a String containing servlet description
      • writeFile

        protected void writeFile​(javax.servlet.http.HttpServletResponse response,
                                 File file)
                          throws IOException
        write a file to the output
        Throws:
        IOException
      • writeErrorMessage

        protected void writeErrorMessage​(javax.servlet.http.HttpServletResponse response,
                                         String message)
                                  throws IOException
        Write a html page as error
        Throws:
        IOException
      • createFileUrl

        protected String createFileUrl​(javax.servlet.http.HttpServletRequest request,
                                       File f)
        Create the url to the file
      • writeFileToHtml

        protected void writeFileToHtml​(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       File file)
                                throws IOException
        Write a link to the file in html
        Throws:
        IOException
      • getCorrectedFile

        protected File getCorrectedFile​(String fileString)
        Get the corrected File (relative to jvm or absolute)
      • writeFileNotFoundMessage

        protected void writeFileNotFoundMessage​(javax.servlet.http.HttpServletResponse response,
                                                String fileString)
                                         throws IOException
        Write a file not found error message
        Throws:
        IOException