1 Reply Latest reply on Aug 2, 2006 5:06 PM by one_special_user

    Folder with public access

    orkus9

      Hi,

      i use jboss 4.0.2.

      I wrote a java-programm thats generating files (generic jpg´s). Users shall be able to download the files (without authentification).
      At the moment i use an apache server, where the users can download the files.
      Is there a way, to use jboss like a apache-server. I need a folder, that can be accessed by any users (from web).

      -- Orkus

        • 1. Re: Folder with public access

          You might do it via a Servlet (ok, probably not the best solution *G*):

          public class GetMeTheImagesServlet extends HttpServlet {
          
           // ...
          
           public void processRequest(HttpServletRequest req, HttpServletResponse res) {
           String dir = getServletConfig().getInitParameter("ROOT_DIR");
           String file = req.getParameter("FILENAME");
           String filename = dir + "/" + file;
          
           // create a FileInputStream and
          
           PrintWriter out = response.getWriter();
           response.setContentType("text/text;charset=UTF-8");
          
           // create a FileInputStream for filename and pipe the bytes to out
          
           out.close();
           }
          
           // ...
          
          }
          



          Your jpg-generator puts the images to the ROOT_DIR and your servlet handles out the bytes ;)