Text to HTML filter ver. 1.6

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
 


<filter>
  <filter-name>text2htmlFilter</filter-name>
  <filter-class>com.cj.text2html.text2htmlFilter</filter-class>
</filter>

c) describe mapping for this filter in web.xml. For example, let we do this for .java files:
 


<filter-mapping>
  <filter-name>text2htmlFilter</filter-name>
  <url-pattern>*.java</url-pattern>
</filter-mapping>

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:
 


<filter>
  <filter-name>text2htmlFilter</filter-name>
  <filter-class>com.cj.text2html.text2htmlFilter</filter-class>
  <init-param>
    <param-name>header</param-name>
    <param-value>path_to_your_header_file</param-value>
  </init-param>
  <init-param>
    <param-name>footer</param-name>
    <param-value>path_to_your_footer_file</param-value>
  </init-param>
</filter>

Header (or footer) file will be outputted "as is".
 

    For downloading:   t2hflt.jar
 

 ©  Coldbeans     Comments?

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

     

Also in JSOS: