File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSP
Bookmark "Putting a class into a JSP Page" Watch "Putting a class into a JSP Page" New topic

Putting a class into a JSP Page

Rich Barry

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

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
I agree. Here's the link:
subject: Putting a class into a JSP Page
jQuery in Action, 3rd edition