FileManager servlet ver. 4.0

This Java(tm) servlet implements FileManager. You can use this servlet for example for remote site management: upload/download files, copy/move files, edit files etc. The main advantage is the usage HTTP protocol only for access to your host. So this approach is free from any firewall's restrictions.

How to use it:

a) copy fmanagerPackage.jar into WEB-INF/lib

b) describe FileManager servlet in web.inf file:
 


    <servlet>
     <servlet-name>FileManager</servlet-name>
     <servlet-class>com.jsos.fmanager.FileManager</servlet-class>
     <init-param>
      <param-name>config</param-name>
      <param-value>path_to_your_configuration_file</param-value>
     </init-param>
    </servlet>

c) define a mapping for FileManager servlet in your web.xml file.
 


    <servlet-mapping>
     <servlet-name>FileManager</servlet-name>
     <url-pattern>/servlet/FileManager</url-pattern>
    </servlet-mapping>

now you can run this servlet:
 

http://your_host/servlet/FileManager


 or

http://your_host/servlet/FileManager?some_your_directory

Parameter config is optional. This parameter lets you define some configuration settings as an initial parameter for your servlet. You must set a path to the configuration file as an initial parameter for FileManager servlet.

Configuration file is a text file, each line describes one parameter in the form of

    parameter=value

Empty lines and any line starts with # or // are ignored.

Current version supports the following list of parameters:

# base (initial) directory. By default it will be the root directory of your servletunner.
dir=your_directory

# title (by default is empty - no title)
title=My Files

# style. Describes a link for your CSS style file. By default is empty. E.g.:
style=/css/mystyle.css

# background color (by default is #3366FF)
bgcolor=your_color

# foreground color (by default is #FFFFFF)
fgcolor=your_color

# color for visited directories (default is #FFFF00)
visicolor=your_color

#font size (by default is current browser's font)
size=your_size

#font face (by default is current browser's font)
face=your_font_face

# file extensions for visible files. Here you can set commas separated
# list of extensions. Only such files will be visible. By default
# this parameter is empty (all files are visible)
show=txt,xml,ini

# file extensions for text editor. Here you can set commas separated list of
# extensions. All such files are editable through this servlet.
# By default it is:  txt,htm,shtml,html,java,jsp,cpp,h,jsp,pl,sh,csh,xml,bat,ini
# E.g. :
edit=log,ini,htm,,txt

# head. You can set here some file contains any html-code. This code will be
# outputted at the beginning of the each page. So you can set for example some banners.
# By default this value is empty
head=path_to_your_file

# Look and feel mode. By default it is 1 (list of files like Norton Commander for example)
# 2 means Explorer like view
mode=1

# security mode. Default value is 0 - user may see any available directory
# on your server. If you set it to 1 user may see only initial
# directory and any directory below
security=1

# enable/disable functions. Possible values are 1 (enabled) or
# 0 (disabled). By default all actions are enabled.

# enable/disable uploading. Default value is 1
upload_enabled=1

# enable/disable edit. Default value is 1
edit_enabled=1

# enable/disable create directories
mkdir_enabled=1

# enable/disable copy files
copy_enabled=1

# enable/disable move/rename files
rename_enabled=1

# enable/disable delete files
delete_enabled=1

# how to open files. Default value is 0 - open in place, 1 - open in the
# separate window
window=0

# maximal size for uploaded file (in bytes). By default size is unlimited
maxFileSize=10000

# authorization flag (See Authorization section below)
authorized=attribute_name

# login page
login=your_page

# Date format. By default will use full date.
# You may set here format for date. E.g.:
date=dd/MM/yyyy

# localization support. You can set character encoding for input parameters
# here. Default value is ISO-8859-1
encoding=Cp1251
 

Authorization

You may incorporate this servlet into your portal where your users will be authorized. In order to prevent access to files from not authorized visitors you may use authorized parameter in your config file. Servlet assumes that your authorization procedure will put some object into session (as a flag for authorized users). And name for this object should be described for FileManager as a parameter authorized. Servlet checks session and if there is no such attribute than request will be forwarded or redirected to the page, described as a parameter login.

If login value starts with http than request will be redirected to that site. Otherwise servlet assumes a local resource and forwards request.

Note:

1. You can save such configuration file anywhere on your server. Just use the proper path for setting servlet's parameter. Short path (just name of the file) means that your configuration file is saved under the root (docBase) directory of your container.

2. Evaluation version adds an exta © information to the edited file and restricts size for the uploaded files.

 

    For downloading:   fmanagerPackage.jar

    Sample of config file: fmconf
 

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.