geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olivier Voutat" <olivier.vou...@gmail.com>
Subject Re: Access to a directory
Date Tue, 04 Apr 2006 16:03:44 GMT
Thanks Mario.

Olivier Voutat

On 4/4/06, Mario Rübsam <mr@coderesearch.com> wrote:
>
> Hi,
>
> the simple way is to write a Servlet to do that static serving.
> This is not the most performant way but if you have only a few
> files to serve...
>
> Here is some _simple_ servlet code for that:
>
> public void doGet(HttpServletRequest pRequest, HttpServletResponse
> pResponse)
>    throws IOException, ServletException
> {
>         String tPath = pRequest.getPathInfo();
>
>          try {
>              PrintWriter tOutput = pResponse.getWriter();
>
>              String tHttpRoot = "/home/oliver/archives";
>
>              InputStreamReader tInput = new InputStreamReader(
>                new FileInputStream(tHttpRoot + tPath));
>
>              char tBuf[] = new char[4096];
>
>              for ( ;; ) {
>                  int tSize = tInput.read(tBuf);
>                  if (tSize == -1)
>                      break;
>                  tOutput.write(tBuf, 0, tSize);
>              }
>
>              tInput.close();
>              tOutput.close();
>          } catch (IOException tIOEx) {
>              pResponse.sendError(404, "resource not found");
>          }
> }
>
>
> -Mario
>
>
>
> Olivier Voutat wrote:
> > Lol, one more question:
> >
> > I have a directory: /home/oliver/archives/
> >
> > that I want it to be accessible externally trough webbrowser. How do I
> > need to configure it in Geronimo ?
> >
> > Best Regards
> > --
> > Olivier Voutat
> > Rua Praia de Muriú, 9188
> > Cep 59092-390 / Natal - RN
> > Tel: (84) 3219-0427 Cel: (84) 9977-3917
>
>
>


--
Olivier & Cidiane Voutat
Rua Praia de Muriú, 9188
Cep 59092-390 / Natal - RN
Tel: (84) 3219-0427 Cel: (84) 9977-3917

Mime
View raw message