A JSP page gets translated directly into a regular Java file on its way to being comiled into a class file. (The JSP class is a subclass of
Servlet, if I recall correctly.) So anything you can do in a "regular" Java file can be done in a JSP.
As for getting data into a JSP, you can do that by using the GET or POST type of HTTP request to your webserver. Then, in your JSP code, use request.getParameter(argname) to get the passed in value.
For instance if you call
http://server/blah.jsp?myname=Muralidhar and have the following code in the JSP:
...
you should see the input parameter.
Yes, I know that the above code could be consolidated to...
...but I wanted to show getting the URL parameter and generating some output as separate steps.
So you can stick all of Mr. Luke's FileOps code right into your JSP. There is a way to add addtional methods to your JSP/Servlet.
If you wanted to make your JSP look as nice as possible (at the cost of extra Java and XML overhead) you could define a custom tag library. That way your JSP code would just have something like
This would more impressive for your directory example than it is for this getname example.
Ryan
[ April 12, 2005: Message edited by: Ryan McGuire ]