This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes File Upload from Servlet Using JCIFS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "File Upload from Servlet Using JCIFS" Watch "File Upload from Servlet Using JCIFS" New topic
Author

File Upload from Servlet Using JCIFS

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
I am tying to get the following servlet to work with JCIFS but I get an error:

SystemOut O java.io.FileNotFoundException: smb:\webergv;xxx:xxx@gvsvr03\drawings\wgen\pre_pdf\sourcefiles\862000\862144B1.rtf (The filename, directory name, or volume label syntax is incorrect)


Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Can you independently verify that there is a file at?

gvsvr03\drawings\wgen\pre_pdf\sourcefiles\862000\862144B1.rtf

Can you independently verify that you have permission to?

smb:\webergv;xxx:xxx@gvsvr03


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Martijn Verburg wrote:Can you independently verify that there is a file at?

gvsvr03\drawings\wgen\pre_pdf\sourcefiles\862000\862144B1.rtf

Can you independently verify that you have permission to?

smb:\webergv;xxx:xxx@gvsvr03


Yes to the above. However, I have changed my code and got it to work from my workbench using local server host but when I move it to the production server(iSeries - AS400 server) it says in file does not exist. How can I get the servlet to see a file on the client so it can be uploaded?


Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

smb:\webergv;xxx:xxx@gvsvr03 is the bit I'd be investigating (I've never seen that protocol used directly from java, it's Samba right?). Can you write a small stand alone class/method to test that you can connect via this method? Try connecting to a different server and/or using different credentials and/or looking for a different file (perhaps one at the root level of the server file system).
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Martijn Verburg wrote:smb:\webergv;xxx:xxx@gvsvr03 is the bit I'd be investigating (I've never seen that protocol used directly from java, it's Samba right?). Can you write a small stand alone class/method to test that you can connect via this method? Try connecting to a different server and/or using different credentials and/or looking for a different file (perhaps one at the root level of the server file system).


I don't understand because the JCIFS library was suggested by another JavaRanch person. I am currently using it to read directory contents. And it works just fine locally.

My code is breaking on the FileInputStream line.

SystemOut O No such path or directory. C:\SDETest.rtf
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I thought you said above that you had it working locally?

However, I have changed my code and got it to work from my workbench using local server host but when I move it to the production server(iSeries - AS400 server) it says in file does not exist.


Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Martijn Verburg wrote:I thought you said above that you had it working locally?



Steve Dyke wrote:

That is correct:

I don't understand because the JCIFS library was suggested by another JavaRanch person. I am currently using it to read directory contents. And it works just fine locally.

My code is breaking on the FileInputStream line.

SystemOut O No such path or directory. C:\SDETest.rtf


The FileInputStream does not fail when I run on local Application Server just on production server. It is behaving like when ran from production application server that it is trying to find the file on that local server instead on the client machine.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Oh, OK I think I was looking at the wrong problem. So the real problem is that



Is returning you a list of Items who's names are like "C:\SDETest.rtf", so when you execute:



It can't find it on the server because "C:\SDETest.rtf" doesn't exist.

So question is, where _is_ SDETest.rtf on the server? And why isn't the item.getName() returning the real location?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Martijn Verburg wrote:

So question is, where _is_ SDETest.rtf on the server? And why isn't the item.getName() returning the real location?


What other property or method of FileItem can I use to get the real location?
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Martijn Verburg wrote:
It can't find it on the server because "C:\SDETest.rtf" doesn't exist.

So question is, where _is_ SDETest.rtf on the server? And why isn't the item.getName() returning the real location?


I have changed the FileInputStream to:



This seems to work but is this the correct way?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

I would argue that is a better way yes, as you're wanting to deal with data streams as opposed to a physical file.
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Martijn Verburg wrote:I would argue that is a better way yes, as you're wanting to deal with data streams as opposed to a physical file.


Thanks for all your help. I have just started developing in Java and have a long way to go.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

No worries! Glad you were able to solve the problem (always the best way to learn!)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Upload from Servlet Using JCIFS
 
Similar Threads
Upload a File Using jQuery
Problem with File Being Written
Display a String on a Web Page
Getting Error on Upload Process
Adding Double Quotes to My String