Folder Creation On Server
Dear All,
I had created a web-application which allows a user to create a named folder with his/her choice on the server which works locally but when i deployed the war of it on the Godaddy it throws a exception as
Caught Exception: java.security.AccessControlException: access denied (java.io.FilePermission /var/chroot/home/content/b/r/i/bringlifeto/html/MyDemoDirApp/demodir/testdir write)
Here is the link, to give you a clear idea what exactly I am talking about,
[Test Link|www.bringlife2.com/MyDemoDirApp/jsp/index.jsp]
For your reference here is the code
index.jsp
<html>
<head><title>Custom Directory Creation On Server</title></head>
<body>
<center>
<h1>Customized Directory Creation On Server</h1>
<form method="post" action="/MyDemoDirApp/UserDirDemo">
<table>
<tr>
<td>Enter Name For Your Directory</td>
<td> </td>
<td><input type="text" name="dirName" /></td>
</tr>
<tr>
<td><input type="submit" value="Create Directory"/></td>
<td> </td>
<td><input type="reset" value="Reset"/></td>
</tr>
</table>
</form>
</center>
</body>
</html>
UserDirDemo.java
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;
public class UserDirDemo
extends HttpServlet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException
response.setContentType("text/html");
PrintWriter out=response.getWriter();
String param=request.getParameter("dirName");
//System.out.println("Param Value="+param);
out.println("<html><head><title>Directory Creation On Server</title></head>");
out.println("<body><center>");
out.println("<h1>Directory Creation On Server</h1>");
ServletContext servletContext=getServletContext();
out.println("<br><h3>servletContext: "+servletContext+"</h3>");
String realPath=servletContext.getRealPath("/");
out.println("<br><h3>realPath: "+realPath+"</h3>");
try
//File f=new File(realPath+"/images/testdir");
File f=new File(realPath+"/"+param+"/testdir");
f.mkdirs();
out.println("<br><h3>Absolute Path="+f.getPath()+"</h3>");
catch(Exception e)
out.println("<br><br><strong><i>Caught Exception:\n\t"+e+"</i></strong>");
out.close();
out.close();
} As I know, the only way to create folder is java.io package. Is there some thing wrong with my code. How can I sort out this issue.
Any help is appreciated
Thanks,
Arpit
Edited by: goldie_gold on Oct 4, 2009 12:30 AM
Hey Balus,
Thanks for replying. I have read on net that the Java Security Manager can set various permission in Policy file inside the tomcat/conf directory. Is the exception bcoz of the the SM of GoDaddy might not have granted permission for writing or say creating folder or uploading file at runtime to a particular folder inside my webapplication.
I apologize, I might not have used correct technical terms above as I am a newbie and hope you will understand what i am trying to say.
Awaiting your reply.
Arpit
Similar Messages
-
Dynamic folder creation on server
hi all,
i'm working with 9i and using webutil for file tranfer from client to server now i want this uploaded file to be stored in a folder created dynamically on the server..any helpcreate the procedure in your form. below is my sample codes:
PROCEDURE chkstatus_mkdir_4ws( wk_ip_adr in varchar2,
usr_name in varchar2,
pss_wrd in varchar2,
accnt_ok out boolean) IS
ftp_dir_file UTL_FILE.FILE_TYPE;
ftp_log_file UTL_FILE.FILE_TYPE;
ftp_dir_file_name varchar2(40);
ftp_log_file_name varchar2(40);
ftp_command varchar2(60);
veh varchar2(6) := LOWER(NAME_IN('GLOBAL.VEHICLE_LINE'));
phs varchar2(25) := LOWER(NAME_IN('GLOBAL.DESIGN_PHASE'));
tid varchar2(20) := LOWER(NAME_IN('GLOBAL.TNUMBER'));
Oracle_dir varchar2(6);
v_ErrorCode number(8); ---PROBLEM HERE
v_ErrorText varchar2(200);
v_str1 varchar2(500);
Begin
--- build the ftp directive file
Oracle_dir := '/tmp';
ftp_dir_file_name := usr_name || '_ftpcm_dir';
ftp_log_file_name := usr_name || '_ftpcm_log';
ftp_dir_file := UTL_FILE.FOPEN(Oracle_dir, ftp_dir_file_name, 'W');
UTL_FILE.PUTF(ftp_dir_file, 'open %s\n', wk_ip_adr);
UTL_FILE.PUTF(ftp_dir_file, 'user %s %s\n',usr_name,pss_wrd);
UTL_FILE.PUTF( ftp_dir_file, 'cd hlink.projects\n');
UTL_FILE.PUTF( ftp_dir_file, 'mkdir e3d\n');
UTL_FILE.PUTF( ftp_dir_file, 'cd e3d\n' );
UTL_FILE.PUTF( ftp_dir_file, 'mkdir %s\n', veh );
UTL_FILE.PUTF( ftp_dir_file, 'cd %s\n', veh );
UTL_FILE.PUTF( ftp_dir_file, 'mkdir %s\n', phs );
UTL_FILE.PUTF( ftp_dir_file, 'cd %s\n', phs );
UTL_FILE.PUTF( ftp_dir_file, 'quit\n' );
UTL_FILE.FCLOSE(ftp_dir_file);
--- invoke the ftp command to run the directive file----
ftp_command := 'ftp -n -v < '
|| Oracle_dir || '/' || ftp_dir_file_name
|| ' > '
|| Oracle_dir || '/' || ftp_log_file_name;
host(ftp_command);
--- Read results from ftp log file to determine if supplied account worked ok
ftp_log_file := UTL_FILE.FOPEN(Oracle_dir,ftp_log_file_name, 'R');
accnt_ok := FALSE;
LOOP
BEGIN
UTL_FILE.GET_LINE(ftp_log_file,v_str1);
EXCEPTION
WHEN NO_DATA_FOUND THEN
message('The workstation selected is not reachable from DTDB application.');
message(' ');
EXIT;
END;
IF INSTR(v_str1,'230') > 0 THEN
accnt_ok := TRUE;
EXIT;
ELSIF INSTR(v_str1, '530') > 0 THEN
message('The incorrect User Name or Password was supplied.');
message(' ');
EXIT;
End IF;
END LOOP;
UTL_FILE.FCLOSE(ftp_log_file);
--- Exception handeling
Exception
When UTL_FILE.INVALID_OPERATION THEN
UTL_FILE.FCLOSE(ftp_dir_file);
Message('INVALID OPERATION... ftp 2 workstation');
WHEN UTL_FILE.WRITE_ERROR THEN
UTL_FILE.FCLOSE(ftp_dir_file);
Message('WRITE ERROR.... ftp 2 workstation');
WHEN UTL_FILE.INVALID_PATH THEN
UTL_FILE.FCLOSE(ftp_dir_file);
Message('WRONG PATH... ftp 2 workstation');
WHEN UTL_FILE.INVALID_MODE THEN
UTL_FILE.FCLOSE(ftp_dir_file);
Message('WRONG MODE... ftp 2 workstation');
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
UTL_FILE.FCLOSE(ftp_dir_file);
Message('Invalid file handle "ftp_dir_file" ftp 2 workstation ');
WHEN OTHERS THEN
UTL_FILE.FCLOSE(ftp_dir_file);
v_ErrorCode := SQLCODE;
v_ErrorText := substr(SQLERRM, 1, 200);
message('Just known Internal Error: '||v_ErrorCode||'=>'||v_ErrorText);
End; -
Directory or Folder creation in server
Hi,
Is it possible to create a folder or directory in the server through code..Is there any function module or class there..
If there means plz give the sample code..
Another part..After creating the folder is it possible to give full access to the folder..hi check this code ,
For browsing (checking the folder exists or not) you can use the following code:
code
CALL FUNCTION 'EPS_GET_DIRECTORY_PATH'
EXPORTING
EPS_SUBDIR = 'log'
DIR_NAME = 'DIR_TMP'
IMPORTING
DIR_NAME =
EXCEPTIONS
INVALID_EPS_SUBDIR = 1
SAPGPARAM_FAILED = 2
BUILD_DIRECTORY_FAILED = 3
OTHERS = 4
if sy-subrc 0.
"the directory not present.
endif.
[/code]
For creating directory, you have to know the exact path of your server, and then you can use the following code:
code
path = '
172.52.72.651\qfilesvr400\S109XXXX\usr\sap\TST\SYS\test'.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_CREATE
EXPORTING
DIRECTORY = path
CHANGING
RC = rc
EXCEPTIONS
DIRECTORY_CREATE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
PATH_NOT_FOUND = 4
DIRECTORY_ACCESS_DENIED = 5
DIRECTORY_ALREADY_EXISTS = 6
UNKNOWN_ERROR = 7
others = 8
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
<REMOVED BY MODERATOR>
venkat.
Edited by: Alvaro Tejada Galindo on Mar 4, 2008 12:27 PM -
Hi Everybody,
I have requirement to create folders/ sub folders dynamically in a given path (server) and copying a pdf in the created path. Client is using ORACLE 10G AS with Windows.
Thanks in Advance
SatyamWhat kind of application (Java, Forms, PL/SQL etc.) you have that you need to have this created/copied from?
-
Robocopy not copying the folder creation date
We migrate the data between 2 Windowsfile servers using robocopy and it works finew ith issues. Only issue is it doesnt copy the folder creatiopn date from source to destination server, it does copy the file creation date without any issues. Command
we use is as below.
robocopy.exe %1 %2 /COPYALL /MIR /ZB /R:10 /W:2 /TEE /DCOPY /LOG+:robocopy_%3.log
This command is called using a batch file where we specify the source and destination using the below syntax.
call Robocopy_Module.bat "C:\Backup" "C:\Restore"
Kindly advise if this is normal behaviour , if not what is the correct command used to copy the Folder creation dates.I was using like this
Go to CMD prompt,
RUN as Administrator
Type
robocopy "source path" "destination Path" / MIR
It will copy including time stamps.
or create seprate folder in a destination place and copy everything into that folder.
It will work. -
Home Folder Creation w/Active Directory
If this has been asked a million times, just point me to the url for the answer...
I have done the leg work and have the "magic triangle" working - I can login and auth to AD and get my preferences from OD. I want our user's home folders to reside on our Windows server. I have shared out \\server\students on the Windows server and in AD I am pointing their home folder to our Windows server, but I can't get the permissions right. When I point a new user's home folder in AD to our Windows server, it creates the folder \\server\students\jtest.
When the user logs in, none of the subfolders are created. Can someone give me some pointers on how permissions need to be set so the subfolders are created on first login?
This is all pretty new and I'm happy that I got the triangle to work - if I can get this all important piece, I'll be set.
Thx in advance!Hi
A lot of this depends on how many OUs you have; how deep they go; and how many directories you have nested in each OU or the particular OU the directory for home folder creation is within. The accepted 'recommendation' is not more than 3 deep - generally. Having said that I have made it work with OUs 7-10 deep. Gets trickier after that.
In my experience the non-creation of expected directories is generally down to permissions not being assigned properly - as you've guessed. Essentially users must be given read/write access all the way down the nested directories. I have seen permissions assigned correctly to a parent folder, with a set of different permissions applied to the next folder down and the next one along again with the correct permissions applied. Folder creation fails when permissions are set in this way.
What is interesting is the log-in does not fail though you are greeted with the usual "the home folder exists on an SMB or AFP Server etc" dialog box when getting to the desktop. You sometimes get this at the log-in window as well. Although you can also see the message for other reasons - usually down to poor DNS configuration.
You should be able to log in as the local admin and look at the system.log in Console. You should see an error starting with 'NSurl etc etc. . . ' listed. If you do that's an indication it's a permissions problem.
Beyond this and without being there it's difficult to tell?
Hope this helps, Tony -
To create folder in Application server
hi,
How to create folder in application server from presentation server??
how is the program it??
reply me soon...
thx,
s.suresh.hi Suresh
Hope u r having nice day
here i am sending a sample report which can upload the file to Application Server which inturn automatically create folder .
REPORT ZSHR_UPLOAD_TO_APPLICATION .
DATA : BEGIN OF IT_MAT OCCURS 0,
MBRSH LIKE MARA-MBRSH,
MTART LIKE MARA-MTART,
MAKTX LIKE MAKT-MAKTX,
MEINS LIKE MARA-MEINS,
END OF IT_MAT.
DATA : W_DIR(40).
MOVE 'D:\usr\sap\DEV\DVEBMGS00\work\SHR' TO W_DIR.
"SHR" IS A FOLDER NAME TO BE CREATED
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\MAT.TXT'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = IT_MAT
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
OPEN DATASET W_DIR FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
IF SY-SUBRC EQ 0.
LOOP AT IT_MAT.
TRANSFER IT_MAT TO W_DIR.
ENDLOOP.
ENDIF.
CLOSE DATASET W_DIR.
IF USEFUL AWARD POINTS.
REGARDS
HEMASEKHARA REDDY S -
Mac desktop. 10.6.8. Text edit. Not locked. Read and write, not read only. Documents are locking when they are moved from desktop to another folder or saved directly into that folder on the server. Not happening with anyone else but me and the boss's computer so has to be in the properties for my text edit software. Techies can't figure it out after trying for two weeks. Boss can do a cut and paste and put into a new document, but that's starting to become a problem.
Mac desktop. 10.6.8. Text edit. Not locked. Read and write, not read only. Documents are locking when they are moved from desktop to another folder or saved directly into that folder on the server. Not happening with anyone else but me and the boss's computer so has to be in the properties for my text edit software. Techies can't figure it out after trying for two weeks. Boss can do a cut and paste and put into a new document, but that's starting to become a problem.
-
How do I keep my new finder window preference set to open a certain folder on the server?
Since switching to Lion, my new finder window preference keeps resetting itself to default. When I open a new finder window I want it to be a certain folder on our server. This setting was persistent in Snow Leopard. Now I have to keep setting it back, sometimes more than once a day. Please help, its very time consuming to have to click through to get to the folder I use most often every time I open a finder window.
Mac Pro (early 2009)
Processor 2.66 GHz Quad-core Intel Xeon
Memory 8 GB 1066 Mhz DDR3ECC
Graphics ATI Radeon HD 4870 512 MB
Mac OS X Lion 10.7.1 (11B26)Enabling thirds-party cookies is the default and if there aren't any other changes made then Firefox will show "Remember History"
Choosing the "Use custom settings for history" setting doesn't make any changes.<br />
If Firefox shows the "Use custom settings for history" setting then that is an indication that at least one of the history and cookie settings are not the default to make you aware that changes were If all History settings are default then you see "Firefox will: (Never) Remember History" and the custom settings are hidden.<br /> -
Hello there,
At work I use a Mac Pro (like this one: http://www.everymac.com/systems/apple/mac_pro/specs/mac-pro-quad-core-2.8-2008-s pecs.html)... and I have a very weird problem that is really annoying.
I don't have the information (but I can get it tomorrow) on the operating system or any information of the server I am having the issues with. But I was hoping maybe some one else with the same issue might have the answer without all of that information.
We use the server to access, open, edit, save, delete, move, etc... all of the files we are currently working on. No files are ever transfered to our local computer's hardrive and then copied back to the server (don't ask me why, and don't tell me to do that, this is how it's done in the office, and this is what I have to do)...
The issue is this. When I have to delete a folder from the server, which is usually a folder within a folder, and maybe within another folder, and another, and another (meaning it takes me time to look for this), the Finder deltes the folder (and asks if I am sure I want to delete it, because it will be deleted forever since I am deleting it from the server)... and when I say yes, the Finder window that I am currently on (the folder which contains the folder that I am deleting) reverts back to the initial "device-folder" for my local mac pro... meaning the folder which is the main folder of that mac pro, where I can see the mac pro's hard drive, any external hardrives, any usb pen drives, any cds, etc...
So EVERY TIME I delete a folder on the server, which is more than 30 times a day, I get "kicked out" of the foler which contains the folder to be deleted, and gows back to tha "main" folder of my computer, so I have to go back to the server, back to the folder, and sometimes it is a folder, within a folder, within a folder, etc, etc, etc, ... and don't tell me the solution is to create a shortcut on my sidebar for that folder, because the folders are the jobs that I may be working on that day, so I could work on as many as 30 different folders per day, and I do have those in my sidebar, but it is still pretty annoying to have to go back to that folder.
One thing I noticed... SOMETIMES, not all the times... IF I delete two folders instead of one, it won't do it... or IF I drag the folder to the trash, instead of clicking on my "delete" icon on my finder's toolbar, it won't do it... but this is only SOMETIMES. So these are not the solutions either.
I can try to get a screen cap tomorrow of the issue, but if anyone has this same issue and knows how to fix it, plese let me know.
I will also try to get more info on my computers OS and the server.
Thank you,
MWHi PCM1, if i understand well the problem you have is when you click on a URL in a pdf file, the link opens in IE ? Have you checked in the default programs panel to see if all was well set ?
-
How to create the folder in presentation server through pop-up(
Hi Experts,
Can u give me the solution , how to create the folder in presentation server through pop-up(means dynamically, after executing the program , pop-up has to come to create the folderand path)
regards
ram.Use the methods -> DIRECTORY_BROWSE & DIRECTORY_CREATE of the class CL_GUI_FRONTEND_SERVICES
DATA: path TYPE string,
rc TYPE i,
dir_name TYPE string value 'HI'.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_BROWSE
CHANGING
SELECTED_FOLDER = path
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
concatenate path '\' dir_name into path.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_CREATE
EXPORTING
DIRECTORY = path
CHANGING
RC = rc
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Edited by: Kartik Tarla on Sep 23, 2009 5:54 PM -
How to zip the folder in application server?
how to zip the folder in application server?
You can use
open dataset with filter
link:[http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_OS_ADDITION.htm#!ABAP_ADDITION_2@2@] -
How to delete the Folder from sql server 2008
Hi all,
I was trying to delete the folder from sql server 2008 with the below script
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @cmd VARCHAR(8000)
DECLARE @folderName VARCHAR(256) -- filename for backup
SET @folderName = + (CONVERT(varchar(10), GETDATE()-7, 112)) -- 7 days back date folder name
SET @path = 'I:\Backup_Test\' + @folderName -- Folder path
SET @cmd = 'del ' + @path -- Delete
EXEC master..xp_cmdshell @cmd
--Print @cmd
This is not working it was asking the Confirmation (I:\Backup_Test\20100629\*, Are you sure (Y/N)? ) what will i do to the delete the folder.
Thanks,
Prasad R.I would notice you that T-SQL does not play well to do things like that. Do not you want using .net language to delete folders?
Old method is
declare @HR int, @CFOLDER varchar(255),@FSO int
set @CFOLDER='D:\folder\'
EXEC @HR = sp_OACreate 'Scripting.FileSystemObject', @FSO OUT
EXEC @HR = sp_OAMethod @FSO, null, 'DeleteFolder', @CFOLDER
Now regarding to your second question please examine xp_fileexist system stored procedure
CREATE FUNCTION dbo.fn_file_exists(@filename VARCHAR(300))
RETURNS INT
AS
BEGIN
DECLARE @file_exists AS INT
EXEC master..xp_fileexist @filename, @file_exists OUTPUT
RETURN @file_exists
END
GO
-- test
SELECT dbo.fn_file_exists('c:\a.txt')
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/ -
Is there any way to create a folder in presentation server - webdynpro abap
Hello,
My requirement is to create a folder in presentation server using webdynpro abap..
I tried on this CL_GUI_FRONTEND_SERVICRES classes ..but its getting an short dump.
Is there any way to create folder using classes / FM..
Regards,
Praveen kumar reddy s.Hi PRaveen,
Check this.. WD_TEST_APPL_ACFEXECUTE
Check Thamos article..
http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/109b9b52-bc00-2c10-8786-e4c5e96d7e04
go for help..
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/b91539878a2d67e10000000a42189c/content.htm
Cheers,
Kris.
Edited by: kissnas on May 10, 2011 2:24 PM -
Creating a folder in application server in background.
Hi experts,
Is it possible to Creating a folder in application server in background.?
My requirement is like this , every time a PO is created it has to be saved locally.
When atlast i manged to do this, i get stuck again by this CR ,
The PO has to be saved in a folder with the same name as PO number,
I do not know if it is possible.
So as always I am looking for inputs/suggestions or knowledge if you had come across scenario like this one.
Thanks and Regards,
KHi,
You could create a system command in SM69 to create a directory and then use the function module SXPG_CALL_SYSTEM to invoke the command and pass in the directory name as a parameter at run time.
Darren
Maybe you are looking for
-
please help! I need my phone!
-
External optical not recognized
the burner is gone on my mac book pro AGAIN went to an external burner ....samsung portable dvd writer model se-208 ....computer does not recognize it and i cannot burn anything ..it does read ...is there something im missing or have i over look
-
Grid Layout and component locations
Can any one tell me if it is possible to get the location of a Jlabel in a gridLayout using getLocation(). I have 12 labels in each 12 consecutive grids , one below the other . This cycle continues till the input is exhausted. There is no user intera
-
I am running Photoshop Elements 9.0.3. Purchased via educational license. I am planning to either buy a new computer or re-install Micorosoft Windows 7. In either case, how do I transfer my Photoshop to the new situation?
-
Keyframing breaks animation parented across different comps
Hi, My fist post here so please excuse me if it is incorrectly formatted. I am having a problem linking Null Object Controllers to precomps in my character rigs. Here is my setup. I have a character that I controlling his eyelids to make blink. He ey