CSV taglib ver. 1.4

    Custom JSP taglib. This taglib lets you proceed text files in special formats like commas separated values etc. For example:
 


<%@ taglib uri="taglib.tld" prefix="csv" %>

<csv:forEachRow file="c:/data.txt">
  <csv:getField id="A"/>
  <csv:getField id="B"/>
 first column: <%=A%> second column: <%=B%>
</csv:forEachRow>

Body tag forEachRow executes own body for the each row from the given file. Tag getField lets you read (or just print) some column.

Tags are:

forEachRow

Body tag. Executes own body for the each row from the given file. Parameters are:

1) file Describes a file
2) separator Optional parameter. Describes a separator. Default value is , (comma).

getField

Reads the current (next) field from row. Tag saves extracted value in page scope variable (type is java.labg.String) or prints it. Parameters are:

1) id Optional parameter. Describes a page scope variable.

getFields

Reads all the fields from current row and saves them in the page scope array. Parameters are:

1) id Describes a page scope variable. Type is com.cj.csv.Fields. This bean has got the following methods:
int size() - counts fields
String getField(int) - returns a field by the index starting from 0
String getFields() - returns all the fields as java.lang.String[]

for downloading:

Library: csvtag.jar    Description: taglib.tld

© Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.