I have successfully set up Tomcat and I am trying to understand how to import the functionality available in a Java class within a JSP.
Using beans I have been able to set and get data. But is there a simple way to connect to classes that contain more sophisticated functionality. For instance, say if I wanted to know how many files existed in a directory on my C drive. If I were to write a class that lists the files in a directory, then from a JSP I pass a message to that class and the Java code lists the directories and sends back a message, "3 files".
Obviously this is easy to do in a JSP itself:
<%
String filename = "c:/Tomcat/webapps/";
File dir = new File(filename);
String[] children = dir.list();
int size = children.length;
%>
But can anyone suggest a simple way to pass in the filename and return the size using JAVA? I know how to do it with beans, but how do I do it with Java classes?