Formatting Elements from a Set

Hi Guys,

I have in my jsp the following code;

<core:forEach var="s" items="${Sandwiches}">

<tr bgcolor="beige">

<td><center>null</td>

<td><core:out value="${s.bread}"/></td>

<td><core:out value="${s.spread}"/></td>

<td><core:out value="${s.baseFillings}"/></td>

<td><core:out value="${s.extraFillings}"/></td>

<td><core:out value="${s.seasonings}"/></center></td>

The values bread, spread, etc, are elements of a set. They are output on the jsp page as;

[Tomato, Mixed Salad, Sliced Onion]

and

[Ham, Chedder Cheese, ]

However I want to format the output and get rid of the brackets. Is this possible?

Message was edited by:

DontKnowJack

[1066 byte] By [DontKnowJacka] at [2007-11-26 18:40:05]
# 1
Can you post the entire *relevant* code , so that we can run it on our systems to test it out first?
appy77a at 2007-7-9 6:14:07 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

The relevant code is pretty large and I am also using the spring MVC framework. In short. a parses is used to read each individual word in a text file and store it in the sets bread, spread, etc. These are then passed on to the view and then displayed on the webpage. The following code is used to read the text file;

public Set parse(File textFile) {

Set sandwiches = new HashSet();

try {

//Initializing and declaring the scanner s and getting it to read the text file

Scanner s = new Scanner(new BufferedReader(new FileReader(textFile)));

// s.useDelimiter(System.getProperty("line.separator"));

s.useDelimiter("\r");

long cnt = 0;

while (s.hasNext())//while there are elements to read in s

//each element constitutes as a line

{

//give a String var the value of the next element in the scanner

String line = s.next();

log.debug(line);

//initiate an object of type Sandwich and give it the value returned by calling

//the parseLine Method. Each line read by scanner s is passed into the method

Sandwich sw = parseLine(line, ++cnt);

//sw now references the object of type sandwich s

//add this to the set sandwiches

sandwiches.add(sw);

}

s.close();

} catch (FileNotFoundException e) {

System.out.println("cannot find the file");

// ignore for now

}

return sandwiches;

}

private Sandwich parseLine(String line, long counter) {

//declare a new scanner and pass it the line

Scanner lineScanner = new Scanner(line);

lineScanner.useDelimiter("#");

//create a new object of the type sandwich

Sandwich s = new Sandwich();

//use this object to call and set the filling elements

s.setBread(lineScanner.next());

s.setSpread(lineScanner.next());

for(int i = 0; i<13; i++) {

String var1 = lineScanner.next();

if (!var1.equals("null")) {

s.addBaseFillings(var1);

}

}

for(int i = 0; i<12; i++) {

String var1 = lineScanner.next();

if (!var1.equals("null")) {

s.addExtraFilling(var1);

}

}

for(int i = 0; i<8; i++) {

String var1 = lineScanner.next();

if (!var1.equals("null")) {

s.addSeasonings(var1);

}

}

s.setId(counter);

//return the sandwich object s

return s;

}

This is called by another class which is also used to pass this info to the web page. Is there anything in JSTL I can use to format the elements in the set or the set itself?

DontKnowJacka at 2007-7-9 6:14:07 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...