*
The moose likes Other Open Source Projects and the fly likes File upload always sends null for the file name? 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 always sends null for the file name?" Watch "File upload always sends null for the file name?" New topic
Author

File upload always sends null for the file name?

Sapumal Bandara
Greenhorn

Joined: Oct 29, 2013
Posts: 26

Guys need a help with this.. Im trying to send these two values to another method implemented in a separate class. but it always catches "null" as the filename at the destination. how to catch the file name ???




Any help?

Regards,
Sapumal.


Be you.. not someone else.. in everything you do..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
I take it you're talking about "value" and "fileName"? Are you saying that within this piece of code they are not null, but in ServiceCaller they are null? That sounds unlikely. I think it more likely that they do no get assigned any values in this code.

My first guess would be that ServiceCaller should only be invoked once, after the for loop has been completed, instead of being called once in each iteration of the loop.


Ping & DNS - my free Android networking tools app
Sapumal Bandara
Greenhorn

Joined: Oct 29, 2013
Posts: 26

Ulf, as you told it seems to be no value is assigning for the fileName and value.. And the file doesn't upload to the given destination which is; File directory = new File(System.getProperty("catalina.base"),"conf") how to solve this? any help is much appreciated..

Thank you,
Sapumal.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
I can't tell from your response if the original problem is now solved after you have moved the ServiceCall invocation out of the loop...?

And the file doesn't upload to the given destination which is; File directory = new File(System.getProperty("catalina.base"),"conf")

Storing anything in one of Tomcat's directories is a bad idea; what if someone uploads a file called "server.xml"? Create a separate directory that is not used for anything else instead. But regardless, I don't see any code that would store anything anywhere...?
Sapumal Bandara
Greenhorn

Joined: Oct 29, 2013
Posts: 26

Here goes the full servlet code..

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
So what is the problem now? Do the two fields have the correct values now? If not, what values do they have now? Have you hooked up a debugger to step through the code?

I see you're still trying to store files in one of Tomcat's directories - still a very bad idea.

And I still don't see any code that would do any kind of actual file storage. Presumably that happens in serviceCaller.callService - we can't opine on code we don't see.
Sapumal Bandara
Greenhorn

Joined: Oct 29, 2013
Posts: 26

Ulf, you are absolutely right. The problem was within the ServiceCall class. The value it returns got the problem. I solved it. And thank you very much indeed for your support, it helped me a lot. Thanks a lot Mr. Marshal !


Regards,
Sapumal.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File upload always sends null for the file name?
 
Similar Threads
Unable To Write Image on Web Host Directory
Unable to write Image on Web Host Directory
request.getParameter() returning null
request.getParameterValues not working
Can't get the selected value of select in JSP