utilities-class for jsp-output

Hello,

I would like to source out some functions for my JSPs. So I decided to put them into a separate class. I was thinking about creating an abstract class that is called "Tools". Usually I need no instance of this class so I would like to call the functions by e.g.

"<%=Tools.mySpecialOutputMethodName() %>".

And here is my newbie-problem, because as far as I know I need to create Instances of classes with the "usebean:" - tag to use them in my JSPs. So how can I access my Tools-class-methods? Or did I start completely wrong?

Thank you vor your hints.

Sebastian

[612 byte] By [sgalonskaa] at [2007-9-19]
# 1

Just import the package containing the Tools class and use it directly:

...

<%@ page import="path.to.package.plus.Tools" %>

...

...

<%= Tools.mySpecialOutputMethodName() %>

...

You're not forced to use the <jsp:useBean ... />

directive.

darrosea at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 2

Tools shouldn't be declared abstract, it should contain static methods.

If you make Tools an abstract class, you would have to subclass it in order to use it.

You have to make the methods static.

public class Tools {

public static String mySpecialOutputMethodName( ) {

// do something here

return someString;

}

}

will make it work....

NLSurfMana at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...