Pranesh_Ashrit 0 Newbie Poster

I have written a code to search a file in a given directory. This runs fine on console. But the same code when i run in jsp does not work as expected.

if(target != null && target.isDirectory())
        {
            for(File f:target.listFiles())
            {
                if(f.isFile())
                {
                    p = Pattern.compile(fileName);
                    m = p.matcher(f.getName());
                    if(m.find())
                        System.out.println("File Found:  "+f.getAbsolutePath());
 else
                        System.out.println("File not found: "+fileName);
                }
                else
                    search(f,fileName);
            }
        }

i have used jsp declaration tag embedding the function which does the above task.

Please guide me to search a file in a given directory using jsp.

The code i have tried in jsp is something like this:

<%!
public static String search(String fileName, String target)
                {
}

%>


<%
List showFiles = search(....);

%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.