• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Finding if files exist.. file on local machine, problems on server

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been using Tomcat/local machine to produce some jsp pages for uploading files.

Files are selected and added to a listbox on a form, once the form is submitted - the filenames in the list are uploaded. Firstly there is a check to see if they exist. Something to the effect of..
for each file.

So typically in the listbox there will be C:\readme.txt or something to that effect. On local machine, this works perfectly - files are found and uploaded. However now, since I put this online to a server (which is an oracle server) when the form is submit -- the file can not be found. Initially when submit, the \'s would be removed.. (filenames which are not found are displayed in an error message) e.g C:\log.txt becomes C:log.txt so I added code to change this to unix separators.. C:\log.txt then becomes C:/log.txt ... still it cant find the file.

My experience with unix is fairly limited, is there a certain of writing a filename like that so that the jsp can pick it up? Or perhaps something I should look into to do with server itself? Any suggestions are appreciated. Thanks
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I dont know about oracle server but in tomcat when you make a file, its by default created in bin directory.So you need to give relative path from bin directory.Same way when you use file exists, you have to give relative path from bin directory.
To see where by default file is created just create file without giving any path.Then set all your path relative to the default path.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you really mean "upload" from the browser client machine to the server, you're outta luck on this approach. The files are on the client and the code is on the server.

You can put

on an HTML page so the form submit will upload the file to the web server. Is that what you need?
 
Mike Ev
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Heya thanks a lot for the replies. I think this could be on the right lines, thanks.

How my page works is.. I'm uploading the file by getting its inputstream and passing that to a method elsewhere (which uploads the file to a database as a BLOB object). The form i'm using currently uses a 'get' rather than 'post' and the action is run on the same page, but I guess I'll have to change that. I've recently read I'll need to upload the file to the server first but instead of then writing it, I'll pass to the inputstream BLOB method.

So I'm guessing I'll have to 'post' each file individually from a file-input object, then I can get it as a File type using this? I'm fairly new to programming of this type so if anyone has any more sites or suggestions on how to do this, that'd be great! Thanks
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic