• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

file upload changing the src path

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
while uploading file i am using

srcPath=config.getServletContext().getRealPath("/")+"uploadedFiles/"+Name;

File savedFile = new File(srcPath);

the srcPath is d:/usr/tomcat/webapps/gblhrm/uploadedFiles/Names

now i want srcPath to be d:/usr/tomcat/webapps/uploadedFiles how can i do this
 
Saloon Keeper
Posts: 28319
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't.

You should NEVER upload files to locations inside of a WAR. Aside from the fact that it will produce major headaches, it's technically a violation of the J2EE spec despite being physically possible in some (but not all) webapp servers (depending on how they're configured).

Designate a dedicated upload directory that's outside of both the webapp AND the Tomcat server directory trees and use that. I normally make that directory path be a configurable option, but that's just for flexibility. The important thing is that the upload directory should not be inside the deployed WAR.
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic