I am learning Java (or more specifically, JSP) and am working on my final project for class. As part of the JSP page I am creating, I want to perform the same string concatenation on each field value to build the appropriate HTML. Normally (with other languages), I would define a function to do this. But I am having trouble getting the syntax right to make this work. Here is the code for my function declaration:
Code:
//Takes a string and builds an HTML value attribute out of it.
String FieldToValue(String str)
{
  String retStr = "";
  if (str.length() > 0) {
    retStr = "value='" + str + "' ";
  }
  return retStr;
}
And here is the error I am receiving:
Code:
<path removed>/_0002fidev_00031_00031_00031final_0002fcustdetail_0002ejspcustdetail_jsp_0.java:63: ')' expected.
                String FieldToValue(String str)
                                          ^
I've tried declaring the function with the public or private keywords, but then Tomcat complains that it wants a statement in their place.

Can I even do this? Or do I need to actually create a .class file (something I really don't have time to play with right now) just to establish a function for use?