Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[SOLVED] Using FilenameFilter inline with JSP?

 
B. Katz
Ranch Hand
Posts: 53
Chrome Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

I've been working on what I thought should be a simple issue, but it's been driving me nuts for 2 days. :-P Doh!

What I need is:
  • To take the name of a file that is being passed from another page.
  • Check it against the filesystem, regardless of case.
  • Return the name of the file that is in the filesystem that matches the passed filename, Upper/Lower-case notwithstanding.


  • What I have so far is:


    And, of course, this returns *everything* in that directory. If I try to use a passed-in variable, I get "Cannot refer to a non-final variable procname inside an inner class defined in a different method"

    So, is there a simple way to get the FilenameFilter to do the comparison for me, or do I have to keep checking against the String Array it produces?

    TIA.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 65225
    95
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Moved to the I/O forum as it has little to do with JSP.

    I still find it hard to believe that people still put Java code in a JSP in 2011.
     
    Paul Clapham
    Sheriff
    Posts: 21416
    33
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    B. Katz wrote:If I try to use a passed-in variable, I get "Cannot refer to a non-final variable procname inside an inner class defined in a different method".


    And what happened when you declared "procname" final?

    Edit: never mind, I see what happened. You want this:


    Or better, if the parameter value is null then there's no point in executing all of that code so just use an if-statement.
     
    B. Katz
    Ranch Hand
    Posts: 53
    Chrome Linux MyEclipse IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks folks.

    That did it! And, it once again proves that old adage of programming; "The longer you work on a problem, the simpler the resolution will be."

    @Paul: If we get to that page, then there shouldn't be any way that procname would be empty or null, but I don't count on that. Thanks much!

    And, @Bear: I was not the one who started the project, but it is in my hands to support it until we can get it switched to something more current (READ: more inline with current standards.).
    Ummm... I'll just leave it at that. ;-p hehe

    Thanks again.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic