This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes createNewFile() on linux hosting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "createNewFile() on linux hosting" Watch "createNewFile() on linux hosting" New topic
Author

createNewFile() on linux hosting

Danilo Cosenza
Greenhorn

Joined: Feb 16, 2009
Posts: 4
Nice to meet you.
I've a strange problem while creating a simple 'hello.txt' in a jsp page.
Here the code:

....

....

I obtain no errors but 'hello.txt' doesn't exists on my linux remote server (Tomcat 6.0 - container).

Any suggestion?
Thanks a lot

Dany
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

Ignoring the fact that you shouldn't be putting Java code in a JSP page...

"hello.txt" is a relative file path which makes no sense in the context of a web app.

Where in the file hierarchy do you want it to go? For example, "/hello.txt" will place it at the root of the web app context.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

"dani dani", please check your private messages for an important administrative matter.
Danilo Cosenza
Greenhorn

Joined: Feb 16, 2009
Posts: 4

Bear Bibeault wrote:Ignoring the fact that you shouldn't be putting Java code in a JSP page...

"hello.txt" is a relative file path which makes no sense in the context of a web app.

Where in the file hierarchy do you want it to go? For example, "/hello.txt" will place it at the root of the web app context.


Thanks Bear.
Doesn't work too (tested some hours ago).
It's possible i've not a permission to write files in the root of my webapp?
When i tested this function on my locale pc (windows - tomcat 6.0), all works fine.
Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
If permission is not an issue print your fileName value in your log so that you can find the cause of the issue.


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
Danilo Cosenza
Greenhorn

Joined: Feb 16, 2009
Posts: 4
Venkat Sadasivam wrote:If permission is not an issue print your fileName value in your log so that you can find the cause of the issue.


Thanks for reply.
I'm not able to do that.
I've tried to store an exel file on server using Apache Poi.




test.xls doesn't appear in /var/www/html but no errors occurred.

Danilo Cosenza
Greenhorn

Joined: Feb 16, 2009
Posts: 4
SOLVED

By clicking on html folder on server, i'v changed the permission to write on it.
All works fine and an excel file is visible.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: createNewFile() on linux hosting