This is a Java servlet filter (as per Servlet API 2.3). text2htmlFilter lets you convert on the fly any text file into HTML document. Filter appends <br> tags for the each line and replaces all special characters like < etc. For example you can use this filter for publishing source codes of your programs.
How to use it:
a) download t2hflt.jar and save it in WEB-INF/lib
b) describe this filter in web.xml
c) describe mapping for this filter in web.xml. For example, let we do this for
.java files:
in this case filter will be on for the each .java file
And now when you request any .java file: http://your_host/your_class.java text2htmlFilter will output it in HTML format.
You can provide your own header and footer for output. They must be described
as initial parameters header and footer:
Header (or footer) file will be outputted "as is".
For downloading: t2hflt.jar
See also JSOS - the largest collection of servlets and filters.
Related links: