Quantcast

Getting all File[] from /WEB-INF/*.jsp ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting all File[] from /WEB-INF/*.jsp ?

BASE Logic, Inc.
This working if running exploded, but not in a war;

def pages = new File("${baseDir}/web-app").listFiles(
                            {dir, file -> file ==~ /.*?\.jsp/ } as FilenameFilter
                    ).toList()*.name

Can someone help me get this list of Files?

---
Thank You…

Mick Knutson, President

BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233

Website: http://www.baselogic.com
Blog: http://www.baselogic.com/blog/
Linked IN: http://linkedin.com/in/mickknutson
Twitter: http://twitter.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting all File[] from /WEB-INF/*.jsp ?

Konstantyn Smirnov
try using smth. like ClassPathResource from Spring
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting all File[] from /WEB-INF/*.jsp ?

Sebastian Hohns
In reply to this post by BASE Logic, Inc.
take a look at FileUtils (commons-io is already included!). No need to do things like this by yourself.

http://commons.apache.org/io/api-1.4/org/apache/commons/io/FileUtils.html#listFiles(java.io.File, java.lang.String[], boolean)

for example:

String[] extensions = {"jsp"}
File directory = new File(servletContext.getRealPath("/"));
println(FileUtils.listFiles(directory,extensions, true))
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting all File[] from /WEB-INF/*.jsp ?

BASE Logic, Inc.
SOLVED!
Thanks for the help:

        <h2>Existing JSP's</h2>
        <table class="config">
            <tr><th colspan=2>Page</th></tr>
                <%
                    // Test this out:
                    String[] extensions = {"jsp"}
                    File directory = new File(request.getRealPath("/"))
                    println(FileUtils.listFiles(directory, extensions, true))

                    def pages = directory.listFiles(
                            {dir, file -> file ==~ /.*?\.jsp/ } as FilenameFilter
                    ).toList()*.name

                    for (String page: pages) {
                %>
                    <tr><td class="key"><a href="${page}">${page}</a></td><td class="value">
                <%
                    }
                %>
            </td></tr>
        </table>


---
Thank You…

Mick Knutson, President

BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233

Website: http://www.baselogic.com
Blog: http://www.baselogic.com/blog/
Linked IN: http://linkedin.com/in/mickknutson
Twitter: http://twitter.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---



On Tue, May 18, 2010 at 3:31 AM, Sebastian Hohns <[hidden email]> wrote:

take a look at FileUtils (commons-io is already included!). No need to do
things like this by yourself.

http://commons.apache.org/io/api-1.4/org/apache/commons/io/FileUtils.html#listFiles(java.io.File,
java.lang.String[], boolean)

for example:

String[] extensions = {"jsp"}
File directory = new File(servletContext.getRealPath("/"));
println(FileUtils.listFiles(directory,extensions, true))
--
View this message in context: http://grails.1312388.n4.nabble.com/Getting-all-File-from-WEB-INF-jsp-tp2220679p2220851.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Getting all File[] from /WEB-INF/*.jsp ?

BASE Logic, Inc.
In reply to this post by Sebastian Hohns
Needed augmentation...

I am displaying these pages:
        <h2>Existing JSP's</h2>
        <table class="config">
            <tr><th colspan=2>Page</th></tr>
                <%
                    // Test this out:
                    String[] extensions = {"jsp"}
                    File directory = new File(request.getRealPath("/"))
                    println(FileUtils.listFiles(directory, extensions, true))

                    def pages = directory.listFiles(
                            {dir, file -> file ==~ /.*?\.jsp/ } as FilenameFilter
                    ).toList()*.name

                    for (String page: pages) {
                %>
                    <tr><td class="key"><a href="${page}">${page}</a></td><td class="value">
                <%
                    }
                %>
            </td></tr>
        </table>


But, What I would really like to do, is be able to filter the HREF output to show the contents of these VXML files like I do in my controller:

    public static String renderFormattedXml(String xml){
        if(xml){
            def stringWriter = new StringWriter()
            def node = new XmlParser().parseText(xml.toString());
            new XmlNodePrinter(new PrintWriter(stringWriter)).print(node)
            return stringWriter.toString()
        }
        else{
            return ""
        }
    }



How can I make my HREF like execute:

    render(contentType: "text/xml"){
                StringUtilities.renderFormattedXml(sb.toString())
            }

---
Thank You…

Mick Knutson, President

BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233

Website: http://www.baselogic.com
Blog: http://www.baselogic.com/blog/
Linked IN: http://linkedin.com/in/mickknutson
Twitter: http://twitter.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---



On Tue, May 18, 2010 at 3:31 AM, Sebastian Hohns <[hidden email]> wrote:

take a look at FileUtils (commons-io is already included!). No need to do
things like this by yourself.

http://commons.apache.org/io/api-1.4/org/apache/commons/io/FileUtils.html#listFiles(java.io.File,
java.lang.String[], boolean)

for example:

String[] extensions = {"jsp"}
File directory = new File(servletContext.getRealPath("/"));
println(FileUtils.listFiles(directory,extensions, true))
--
View this message in context: http://grails.1312388.n4.nabble.com/Getting-all-File-from-WEB-INF-jsp-tp2220679p2220851.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Loading...