This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes How to write a file in a web enviroment ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to write a file in a web enviroment ?" Watch "How to write a file in a web enviroment ?" New topic
Author

How to write a file in a web enviroment ?

Marcio Di Pietro
Greenhorn

Joined: May 30, 2003
Posts: 2
Friends, i'm using the example of upload that comes with the struts.
The example works fine, but when a choose a path to save the uploaded file, i must to pass a concrete path, like "c:/.../img/teste.jpg"
But the application is in the web, hosted in a server in any place.
How can i define the target path to the file be saved in a web enviroment ?


Hey, who are you ?<br />Give me some code.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Check out the ServletContext.getRealPath() method if you want to save the file within the app context, or specify the base path as an init parameter or property.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to write a file in a web enviroment ?