Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Putting a class into a JSP Page

 
Rich Barry
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
want to put this class into a jsp.. and reference it when I need it... can i just dumped it into a
jsp... or do I have to do anything specific to it...
public class areaformat {
public synchronized static String replace(String str, char oldchar, String newstr) {
StringBuffer sb = new StringBuffer(str);
int len = sb.length();
try {
for (int i=0; i<=len; i++) {
if (sb.charAt(i) == oldchar) {
sb = sb.replace(i, i, newstr);
sb.deleteCharAt(i + newstr.length());
i = i + newstr.length() - 1;
}
}
}catch(StringIndexOutOfBoundsException sioobe) {
if (len == 1 && str.equals("'")) {
sb = new StringBuffer(newstr);
}
}
return sb.toString();
}
}

Thx RIch
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what you'll actually be doing is creating an Inner Class in the JSP.
Check out these sites for more info:
Declaring Classes in a JSP
Getting in Touch with your Inner Class
Hope that helps !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic