• Post Reply Bookmark Topic Watch Topic
  • New Topic

Database load problem

 
ellie patterson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Can anyone help me with the following problem. I have a jsp which will check a directory for files and if present and named correctly will upload them into a database. This works fine, all files in the directory are loaded. However now I want to enhance this to allow users to select which files are loaded.

I have created a separate form which will submit a parameter to the jsp, however this is where it get complicated. What I want to do is send a parameter say 'Group1', which represents 3 values locations (AMS, BRU, BUD), the files for these locations will then only be loaded into the database. The first 3 letters of the filename represent the locations.

This is my code so far, if anyone could point me in the right direction I would be very grateful.

 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a version of File.list() that takes a java.io.FilenameFilter (interface) as an argument. You'll need to implement a FilenameFilter (accept() method) such that it excludes files that don't have the desired prefixes. Check out the API docs for further details.

Hope that helps. If you struggle then repost.

Jules
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ellie p",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
ellie patterson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jules

Thanks for the help. I have got a bit further with this but am a bit confused.

I now have the following code



I have 3 files, (BRU, BUD, GLS), I was expecting 2 of them to be loaded into the database if Group1 is selected but only BRU is loaded. Any idea why this is?

Thanks in advance for any advice you can give me.
 
ellie patterson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I have just realised a silly mistake....I forgot to change the endsWith to startsWith.....it works fine now. Thanks again for your help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!