473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem inCreating File from a file on Linux, With JSP Code

I m using this code to make a file on my Windows Platform, and it is working fine.

But when i run this programme on linux then it is not creating any file...
I have Replaced the path "c:\\atul.txt" to "/home/File/atul.txt" and "d:\\outgain.txt" with "/home/File/outgain.txt"

i have also set the permission for both File and home folder "wrx" it means full permission to the user.

So could any one make it clear why it is not working properly.

<%@ page import="java.io.*" %>
<html>
<body>
<%


FileInputStream in = null;
FileOutputStream outfile = null;
try {
in = new FileInputStream("c:\\atul.txt");
outfile = new FileOutputStream("d:\\outagain.txt");
int c;

while ((c = in.read()) != -1) {
outfile.write(c);
}

}
finally {
if (in != null) {
in.close();
}
if (outfile != null) {
outfile.close();
}
}
%>
Success in creating File!
</body>
</html>
Jun 5 '07 #1
6 1557
JosAH
11,448 Expert 8TB
Your servlet container or web server is probably running as another user. Try
to set the file permissions to rwxrwxrwx and try again.

kind regards,

Jos
Jun 5 '07 #2
Your servlet container or web server is probably running as another user. Try
to set the file permissions to rwxrwxrwx and try again.

kind regards,

Jos

Hi,
Thanks for reply, but i m running the Tomcat as Supper user Account.

and i run the Tomcat as

su - tomcat -c/usr/local/tomcat/startup.sh


and as i have already set the permission to "/home" and "File " folder in which the File will be created.

am i right or Wrong?
Jun 5 '07 #3
dmjpro
2,476 2GB
I m using this code to make a file on my Windows Platform, and it is working fine.

But when i run this programme on linux then it is not creating any file...
I have Replaced the path "c:\\atul.txt" to "/home/File/atul.txt" and "d:\\outgain.txt" with "/home/File/outgain.txt"

i have also set the permission for both File and home folder "wrx" it means full permission to the user.

So could any one make it clear why it is not working properly.

<%@ page import="java.io.*" %>
<html>
<body>
<%


FileInputStream in = null;
FileOutputStream outfile = null;
try {
in = new FileInputStream("c:\\atul.txt");
outfile = new FileOutputStream("d:\\outagain.txt");
int c;

while ((c = in.read()) != -1) {
outfile.write(c);
}

}
finally {
if (in != null) {
in.close();
}
if (outfile != null) {
outfile.close();
}
}
%>
Success in creating File!
</body>
</html>

Could u tell me the print stack trace in details?
Then i would be able to solve ur problem.

Kind regards,
Dmjpro.
Jun 5 '07 #4
Could u tell me the print stack trace in details?
Then i would be able to solve ur problem.

Kind regards,
Dmjpro.

No Stack Trace is there,
Actually code is not having any problem, it is executing fit and fine but the "outFile.txt" is missing,i.e this file is not created yet.

one more thing is there, that when i executed .java file with same code then the "OutFile.txt " is created with no problem. but jsp file is creating problem but not giving any Exception or problem at all.
PLZ do needfull
Jun 5 '07 #5
dmjpro
2,476 2GB
No Stack Trace is there,
Actually code is not having any problem, it is executing fit and fine but the "outFile.txt" is missing,i.e this file is not created yet.

one more thing is there, that when i executed .java file with same code then the "OutFile.txt " is created with no problem. but jsp file is creating problem but not giving any Exception or problem at all.
PLZ do needfull
Hmm ... I see.
Do one thing .... Handle the exception urself in JSP page and try to print the exception message in the page then tell me the specific error message u get.
Have a good day.

Kind regards,
Dmjpro.
Jun 5 '07 #6
JosAH
11,448 Expert 8TB
No Stack Trace is there,
Actually code is not having any problem, it is executing fit and fine but the "outFile.txt" is missing,i.e this file is not created yet.

one more thing is there, that when i executed .java file with same code then the "OutFile.txt " is created with no problem. but jsp file is creating problem but not giving any Exception or problem at all.
PLZ do needfull
Maybe Tomcat does a 'chroot' (changes the root position of the file system).
Try to find the file:
Expand|Select|Wrap|Line Numbers
  1. find / -name OutFile.txt -print
  2.  
If you can find it anywhere in the file system my guess was right ;-)

kind regards,

Jos
Jun 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Rami A. Kishek | last post by:
Hi - this mysterious behavior with shelve is just about to kill me. I hope someone here can shed some light. First of all, I have this piece of code which uses shelve to save instances of some...
0
by: Jose Vicente Nunez Z | last post by:
Greetings, I wrote a couple of custom dummy extensions in Python (one a pure Python and the other a C) and i managed to compile and install them without a problem: $ make python2 setup.py...
0
by: Jeremy Sanders | last post by:
Hi - I'm trying to build a Psyco rpm on Fedora 1. I try the command xpc5:~/psyco-1.1.1> python setup.py bdist_rpm this fails with: .... copying dist/psyco-1.1.1.tar.gz ->...
0
by: wab104 | last post by:
I compiled Python on one Linux box and copied it to another Linux box. This causes an import problem: >>> import urllib Traceback (most recent call last): File "<stdin>", line 1, in ? File...
1
by: timothy.williams | last post by:
I'm trying to install wxPython 2.5.3.1 using Python 2.3.2 on a Fedora 2 machine. I have python in a non-standard place, but I'm using --prefix with the configure script to point to where I have...
2
by: Robert Stearns | last post by:
After working well for most of a week, my application with the mysterious php/db2 problem is now failing again. No one has worked on the php code this week. We're running DB2 8.1.5, php 4.3.6...
7
by: git_cs | last post by:
Hey, guys and gals Somedays ago, I had asked for the DES algorithm in C language. Although I have written the algorthim in C myself, I am facing a peculiar problem, which I hope some of u guys and...
2
by: baileyxia | last post by:
Hi, all I am learning how to import c code in python. Here is my simple code foo.c: ===================== #include <Python.h> void bar() { printf("Hello! C wrap!"); } static PyObject...
5
by: Giff | last post by:
Hi, I hope this post is not too OT. I am porting some code from Windows to Linux and I am having a problem with a routine that skips comments and empty lines in a txt file. The following code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.