aspose file tools*
The moose likes JSP and the fly likes Putting a class into a JSP Page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Putting a class into a JSP Page" Watch "Putting a class into a JSP Page" New topic
Author

Putting a class into a JSP Page

Rich Barry
Greenhorn

Joined: Jan 28, 2002
Posts: 19
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

Joined: Oct 17, 2001
Posts: 4313

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 !


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Putting a class into a JSP Page