Copy file in the context on web server

Respected Sir,
I want to copy a file in the web application context & retrieve from there, I try to copy file using output stream with the help of netbeans6.1 but the file is copied in the config folder in domain1 folder in domain folder on sun web server 9.0. I also tried to copy file by giving path to the context using 'request.getContextPath()' but it gives exception 'path nopt found'. how can i copy file in my context (my application folder). please help me.
Thanking you.

Ajit-Singh wrote:
Respected Sir,
But the getServletContext().getRealPath("/"); is depricated API in the current version.?? No it isn't. At least it isn't marked as such [in the API|http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)]. What version are you using, cause it wasn't deprecated in the previous version (J2EE 1.4) either?
is there any other solution except this because it gives us the real path of file system on server side is there any other option, if yes, please give detailed information. can we copy file in the context folder by using URL or relative path etc.
Thanking you

Similar Messages

  • JSP to Upload file from client machine to Web Server!

    Hi,
    I want to upload a file from client machine to web server in order to send it as email attachment, How can I do it? After uploading the file the class should give me the path where the file is stored on the web server and the file name in return!
    I know the HTML <file> field but dont know how to copy it on web server, HTML Part will be:
    <FORM ENCTYPE="multipart/form-data"
    method="POST" action="My.jsp">
    <INPUT TYPE="file" NAME="mptest">
    <INPUT TYPE="submit" VALUE="upload">
    </FORM>
    Please help!
    Thanks,
    - Rahul

    You can use cos.jar provided by O'Reilly from http://www.servlets.com/cos/. Take a look at com.oreilly.servlet.multipart.* classes.
    Package is provided with source, classes, documentation and, of course, ready-to-use jar file.
    It is really usefull and - ready!

  • Can't copy file from SAP-directory to FTP server

    Hello,
    I can't copy files from the SAP server to the FTP server. The file is created with OPEN DATASET and CLOSE DATASET commands and is placed in the SAP-directory S:\usr\sap\DEV\DVEBMBGS00\work.
    I can see and read the file with transaction al11, so I know it's there.
    But the FTP command always gives the same error:
    S:\usr\sap\DEV\DVEBMBGS00\work\[FILENAME] errno 22: invalid argument
    I can connect to the FTP, but the put command keeps failing. Somehow, the file in the SAP directory can't be read, it seems, even when
    Any ideas?
    Thanks in advance.
    Dave

    Ok, I found out that I have to use SAPFTPA as RFC destination type, instead of SAPFTP, otherwise the folders can't be located.
    But with SAPFTPA I can't seem to connect to the FTP server. I've tested the connection with sm59 and it works, but for the FTP it doesn't work. When I use SAPFTP as destination type, it still works.
    What can I do?
    Thanks.

  • When using the built in web server, is there a way to specify a different

    When using the built in web server, is there a way to specify a different error handler when you try to access a NON .CFM file? Right now I get the standard:
    java.io.FileNotFoundException: filename.ext
    Is there any setting to override this and direct the message to your own .cfm template? The missing template handler in the CF Admin work only for .cfm files.
    Thx

    The in-built web server for ColdFusion 8 is JRun. I am on ColdFusion 10, however, and so cannot offer hands-on advice. (CF10 replaced JRun with Tomcat.)
    My guess is that you have to modify the file {CF_ROOT}/WEB-INF/web.xml. Don't forget to create a back-up first!
    You may then proceed as follows.
    1) In the ColdFusion root (CF_ROOT), create the file myCustomFileNotFound.cfm. Give it some content, like
    My custom File Not Found page. Current time: <cfoutput>#now()#</cfoutput>
    2) Open the file {CF_ROOT}/WEB-INF/web.xml in a text editor. Add the following error-handling specification just before the end tag </web-app>:
    <error-page>
    <error-code>404</error-code>
    <location>/myCustomFileNotFound.cfm</location>
    </error-page>
    Save the file web.xml.
    3) Restart ColdFusion. Test by browsing to a URL requesting filename.ext

  • Recent backups fail: "An error occurred while copying files to the volume."

    I recently moved to a new place and set up Time Capsule as a bridge. Backups were working fine for the first couple days but then, out of the blue, I got a message that said the password I entered for Time Capsule was incorrect. I entered the correct password and hit OK. Time Machine was able to connect but now backups fail with this error: "Unable to complete backup. An error occurred while copying files to the backup volume."
    Time Machine indicates it is "preparing backup" for a few minutes, then sits at "zero of __MB completed" for a long while, finally starts backing up and gets to the end but then fails. Console indicates "unexpected reply from backup server; ignored."
    None of these attempts have fixes my problem:
    --I have deleted my TC passwords in Keychain Access.
    --I have tried downloading the latest Airport Utility and re-entering the TC disk's password in both Airport Utility and in Time Machine preferences.
    --I have restarted my computer and unplugged & plugged back in TC.
    My Internet connection works fine; TC's light is solid green. I can enter Time Machine to restore backups without a problem. The backups just fail every time now. Any ideas?

    The problem really isn't the speed of the backup; it's done in 5-10 minutes, but each time it finishes, TM reports it has failed. I don't believe plugging it in overnight or letting TM try over and over will fix the problem. I've tried to manually start backups a number of times, and have let TM try to start and complete them on its own but they consistently fail.
    It would be an awful shame if I had to delete my old backup--I bought the Time Capsule for the specific purpose of having backups that go back months and I don't want to lose what I've already backed up.

  • Finding out if css file is located on a web server

    Hi,
    how can i know if a css file or any other file is located on a web server from a servlet , JSP?
    should i use getServletContext().getRealPath(...)?
    I need a quick way.
    can someone please give an example?
    Thanks,

    THe most reliable way is doing a HTTP request to its URL see if it does not throw and exception. But this is little slow.
    If your file is static content you can use getRealPath and then check whether the file exists on the path that the getRealPath method return.

  • I need to copy files over the network PSSession . ( Firewall / DMZ / Etc. )

    Hello
    I need to copy files over the network PSSession . ( Firewall / DMZ / Etc. )
    I have a script where I copy from my local server ( server1) to the remote server ( server2 ), but I can´t not make script that will copy from the remote server to my local by my session. From server2 to server1
    Script is as below ...:-)
    HELP : ....
    winrm s winrm/config/client '@{TrustedHosts="SERVER2"}'
        $Source = "D:\test\ok.log"
        $Destination = "D:\test\ok.log"
        $session = New-PSSession -ComputerName SERVER2
    Set-StrictMode -Version Latest
    ## Get the source file, and then get its content
    $sourcePath = (Resolve-Path $source).Path
    $sourceBytes = [IO.File]::ReadAllBytes($sourcePath)
    $streamChunks = @()
    ## Now break it into chunks to stream
    Write-Progress -Activity "Sending $Source" -Status "Preparing file"
    $streamSize = 1MB
    for($position = 0; $position -lt $sourceBytes.Length;
        $position += $streamSize)
        $remaining = $sourceBytes.Length - $position
        $remaining = [Math]::Min($remaining, $streamSize)
        $nextChunk = New-Object byte[] $remaining
        [Array]::Copy($sourcebytes, $position, $nextChunk, 0, $remaining)
        $streamChunks += ,$nextChunk
    $remoteScript = {
        param($destination, $length)
        ## Convert the destination path to a full filesytem path (to support
        ## relative paths)
        $Destination = $executionContext.SessionState.`
            Path.GetUnresolvedProviderPathFromPSPath($Destination)
        ## Create a new array to hold the file content
        $destBytes = New-Object byte[] $length
        $position = 0
        ## Go through the input, and fill in the new array of file content
        foreach($chunk in $input)
            Write-Progress -Activity "Writing $Destination" `
                -Status "Sending file" `
                -PercentComplete ($position / $length * 100)
            [GC]::Collect()
            [Array]::Copy($chunk, 0, $destBytes, $position, $chunk.Length)
            $position += $chunk.Length
        ## Write the content to the new file
        [IO.File]::WriteAllBytes($destination, $destBytes)
        ## Show the result
        Get-Item $destination
        [GC]::Collect()
    ## Stream the chunks into the remote script
    $streamChunks | Invoke-Command -Session $session $remoteScript `
        -ArgumentList $destination,$sourceBytes.Length
        Remove-PSSession -Session $session

    But have will the script look,  if i need to copy from
    From server2 to server1.
    My script copy from server1 to server2 and working, but I need server2
    to server1.

  • My Time Capsule has stopped backing up.  I have an Apple Time Capsule which backs up by wireless. For the last 3 days it has not backed up. I get this message: "The backup was not performed because an error occurred while copying files to the backup disk.

    My Time Capsule has stopped backing up.
    I have an Apple Time Capsule which backs up by wireless. For the last 3 days it has not backed up. I get this message:
    "The backup was not performed because an error occurred while copying files to the backup disk."
    I have gone into Mac Help and followed this down to stage 4:
    under shared it lists my time capsule and my husband's iMac - both use the time machine but we have switched his off temporarily.  Clicking on my Time capsule I get "Connected" and "Sharepoint" - I didn't have to enter connect or password
    I don't understand stage 5: how and where do I select the disk or volume that contains Time Machine backups ?  How do I know which it is? My disk utility lists 160.04 TOSHIBA MK... with sub-heading Macintosh HD.  It also lists (with a "CD" icon) HL-DT-ST DVDRW GS22N
    Under stage 6, how and where do I Locate your backup ? I try dragging my Time capsule from Finder to the Disk Utility side panel but it won't go.  What is my computer's name?
    Please someone help!  I'm completely stumped.
    Thanks,
    Maggie
    Mac Help says:
    If you back up to a Time Capsule or network disk:
    Open the Time Machine pane of System Preferences, and slide the switch to Off.
    Open Time Machine preferences
    Open Disk Utility, which is in the Utilities folder in the Applications folder. 
    Open Disk Utility
    Make sure the Time Capsule or network disk is turned on and available. 
    Open a Finder window, select your Time Capsule or network disk in the Shared section of the sidebar, and click Connect. If necessary, enter your user name and password. 
    On the Time Capsule or network disk, select the disk or volume that contains Time Machine backups. Depending on how your Time Capsule is set up, there may be one or more disks or volumes. 
    Locate your backup, and drag it to the Disk Utility sidebar.You can identify your backup by looking for your computer’s name in the backup’s filename.

    Hello,
    Thanks to the great Pondini...
    http://pondini.org/TM/C3.html

  • Outlook.office365 debug unable to launch the IIS Express Web server 49152

    Using office365 portal to test a mail app.
    I am using VS2013 and have deployed from VS2013 to my office365 portal.
    During the process of starting the debug of the mail app and window pops up stating:
    "Unable to launch the IIS Express Web server.
    Port '49152' is in use."
    Is this error message being given because the portal is refusing the connection or is this from being generated from my PC?
    this is from my "Immediate Window" page:
    Exception was thrown at line 70, column 21 in https://outlook.office365.com/owa/?realm=cisco234.onmicrosoft.com
    0x800a01ad - JavaScript runtime error: Automation server can't create object
    Exception was thrown at line 34, column 25599 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/preboot.js
    0x800a139e - JavaScript runtime error: SyntaxError
    Exception was thrown at line 82, column 543280 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.0.mouse.js
    0x800a01ad - JavaScript runtime error: Automation server can't create object
    Exception was thrown at line 2, column 781790 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.1.mouse.js
    0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'get_$5oW'
    Exception was thrown at line 2, column 604470 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.1.mouse.js
    0x800a138f - JavaScript runtime error: Unable to get property 'get_$1Qf' of undefined or null reference
    Exception was thrown at line 2, column 604470 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.1.mouse.js
    0x800a138f - JavaScript runtime error: Unable to get property 'get_$1Qf' of undefined or null reference
    Exception was thrown at line 2, column 604470 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.1.mouse.js
    0x800a138f - JavaScript runtime error: Unable to get property 'get_$1Qf' of undefined or null reference
    Exception was thrown at line 2, column 604470 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.1.mouse.js
    0x800a138f - JavaScript runtime error: Unable to get property 'get_$1Qf' of undefined or null reference
    Exception was thrown at line 2, column 604470 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.1.mouse.js
    0x800a138f - JavaScript runtime error: Unable to get property 'get_$1Qf' of undefined or null reference
    Exception was thrown at line 2, column 604470 in https://outlook.office365.com/owa/prem/15.0.913.9/scripts/boot.worldwide.1.mouse.js
    0x800a138f - JavaScript runtime error: Unable to get property 'get_$1Qf' of undefined or null reference

    Please post it here as this forum is meant only for Windows server general queries.
    http://community.office365.com/en-us/f/156.aspx
    http://www.arabitpro.com

  • Can't add own application to RemoteApps - "You must specify a file from the RD Session Host server SERVERNAME by using the UNC path....

    Hi, there
    I'm not really pro- at RDS in server 2012 (r1), but I have a problem and don't find anything suitable on internet:
    I'm trying to publish one of my own, unlisted programs to rdweb, but it keeps saying "You must specify a file from the RD Session Host server SERVERNAME by using the UNC path...."
    1) I provided the path in the unc name - when I click "Add.." then i browse the the .exe file via network share, not via local path. So that should be OK
    2) Firewall is turned off and eventhough the exeptions are enabled, both of then, checked
    What else should I do to make this work?

    Okej, I found the sollution:
    You have to specify the path like \\hostname\drive_letter$\path-to-the-program.
    I was doing wrong because i wrote it like \\hostname\ShareName\path-to-the-program.
    I was misleded because the wizard wants me to find the program by clicking, and not by entring the path manualy.

  • Overwriting a File in the KM using web dynpro

    Hello,
    im using the createresource method to upload files into the km using web dynpro.
    (using the following tutorial: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70a60afe-d576-2a10-68bf-9ce3988dc39e )
    however, if i try to upload a file which is already there, it doesnt overwrite it, instead it throws an exception without any additiona info.
    is there any way of doing this?
    many thanks,
    Eli.
    Edited by: Eli Eren on Nov 24, 2008 11:22 PM

    Hi,
    first check, if the resource exists, then decide to create or update content:
        IResource resource = (ResourceFactory.getInstance().getResource(rid, ctx));
        ICollection aCollection=(ICollection)resource;
        // get new resource RID
        RID newResRid = RID.getRID(repository+RID.PATH_SEPARATOR+resourceName);
        // try to find the resource
        IResource newResource = (ResourceFactory.getInstance().getResource(newResRid, ctx));
        if(newResource!=null)  {
          // does exist - update content
          newResource.updateContent(content);
        else  {
          // does not exist - create
          newResource = aCollection.createResource(resourceName, null, content);
    Hope that helps,
    Romano

  • Time machine: An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.

    Time machine backups are failing. I've followed the instructions I found on the Time Machine troubleshooting page (http://pondini.org/TM/Troubleshooting.html) but have gotten to where I don't know what to do next.
    Sequence of events:
    The main error message is always:
    An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.
    Yesterday, I opened Disk Utility and verified the disk. Got this error:
    Error: This disk needs to be repaired using the Recovery HD. Restart your computer, holding down the Command key and the R key until you see the Apple logo. When the OS X Utilities window appears, choose Disk Utility.
    I ran Disk Utility and repaired the hard drive. Then I manually started the backup before going to bed, figuring it was going to take a long time to run. When I got up this morning, the backup had failed with the same "could be temporary" error. I checked the log, which says:
    Starting manual backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:17
    Error: (5) setxattr for key:com.apple.backupd.SnapshotState path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:2
    Deep event scan at path:/ reason:must scan subdirs|new event db|
    Finished scan
    Found 145601 files (11.88 GB) needing backup
    16.1 GB required (including padding), 620.77 GB available
    Copied Zero KB of 11.88 GB, 0 of 145601 items
    Copied 0 files (Zero KB) from volume Macintosh HD.
    Copy stage failed with error:11
    Backup failed with error: 11
    Ejected Time Machine disk image: /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle
    Ejected Time Machine network volume.
    Starting automatic backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/9F8E7957-9C50-49C3-8314-880E5203E3D9
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/
    Does anyone know what the problem is here and what I should do?
    Thanks,
    Tery

    You have repaired your boot drive (which is good) but have you repaired your time machine drive?  I don't own a Time Capsule so I don't know if disk utility can operate on it.  If it can, you should repair it as well.  You may need to erase it and start a new backup.  That happens to time machine volumes from time to time and is why people who are serious about their data never rely on a single source of backup.

  • HT1449 copying files failed. the disk could not be read from or written to.

    Im moving my iTunes to an external hard drive. Its moved about half already and Im now getting this error. I have no idea what file its getting stuck on so I cant remove that file. When I restart it it will say preparing to copy then I get the error right away. I dont want to delete the extrenal and start over if I dont have to.

    Ive already changed the location for my itunes media to my extrenal hard drive so when i click to consolidate files Im getting the error
    copying files failed. the disk could not be read from or written to

  • Time Machine will not complete a system backup and terminates with "Unable to complete backup. An error occurred while copying files to the backup volume.  This follows a problem when Time machne terminated when the volume was almost full.

    On 11/1/2011, Time Machine (TM) terminated with an error message I did not record.  I noted that the drive was full and decided to do a separate complete bootable  system backup using Carbon Copy Clone (CCC), before clearing the TM volume and trying to start it over clean.  Part way through the full system backup CCC put up a message that there was a Physical Problem  "Library/Application Support/Techtool Protection/McIntosh HD/Directory Backup 2011-11-01-16-28-16".  That was about the time that TM malfunctioned, so I assumed they were related.  After starting CCC over a couple of times, and getting the same error message, I let it go through to completion of the backup, which took three or four hours.  I then ran tests using Disk Utility and verified that there was nothing physically wrong with both the internal hard drive and the TM volume.  I also erased and reformatted the TM volume.  However, every time I started Time Machine, it would record a few GB and terminate with "Unable to complete backup. An error occurred while copying files to the backup volume".  I restarted the computer with no change in results.  Note that prior to starting the CCC backup, I "Repaired Permissions", "zapped the PRAM" and "re-set the SMC", hoping to have a clean bootable system on the backup.  I ran Techtool and no problems were found.
    I'm running this on an Intel iMac under 10.5.8 and recording to a 500GB My Passport drive.  My hard drive is only about half full at 246 GB.  My assessment is that something happened at 16-28-16 on 11/1/2001 to screwup the Backup Directory in the file at "Library/Application Support/Techtool Protection/McIntosh HD/Directory Backup 2011-11-01-16-28-16". My question is, how do I fix it?
    I had just completed writing everything above here, explaining the problems I had been encountering for the past 24 hours.  I had the Time Machine window standing open on the desktop where I could see it, having recentlycleared it after the last termination.  As I was proofing what I had written, I looked at the window and noted that the clock had started a new run for a full back up, since all prior efforts had failed and the TM volume was empty.  As I watched and waited for it to fail again, as it had been doing at about 13 GB, it kept going and going until it just finished a complete backup, about 4.5 hours later, with my having done nothing.  Now my question would have to be - what could possiibly have happened to make it perform this way?   It will be interesting to see if it continue to operate normally, or if the problem will return, in a later backup run.

    jcm21 wrote:
    CCC put up a message that there was a Physical Problem  "Library/Application Support/Techtool Protection/McIntosh HD/Directory Backup 2011-11-01-16-28-16"
    You should not keep those files for long, and probably shouldn't back them up (if you need them at all -- since you do regular backups, I'm doubtful just how worthwhile that feature is).
    "Unable to complete backup. An error occurred while copying files to the backup volume".
    One of Apple's maddeningly incomplete messages. Most likely, there's a problem with a file (quite possibly the one CCC didn't like).  See #C3 in Time Machine - Troubleshooting for details and instructions on finding and fixing it.
    If you continue running the Directory Protection app, be sure to exclude your Time Machine drive from it (as it will just take up lots of room, and won't help repair your backups if there's a problem);  and exclude the folders it creates from being backed-up by Time Machine (as they'll create large backups, and you probably can't use the backed-up folders anyway), per #10 in Time Machine - Frequently Asked Questions.

  • Can anyone help me?Time Machine couldn't complete the backup to...  An error occurred while copying files. The problem may be temporary. If the problem persists, use Disk Utility to repair your backup disk.  What is the problem?  I've made no changes.

    I recently starting receiving the error message "Time Machine couldn't complete the backup to... An erro occurred while copying files.  The problem may be temporary.  If the problem persists, use Disk Utility to repair your backup disk.  I have had no problems backing up my MacBook Pro 2011 to my Western Digital My Book Live through a Linksys EA4500 router until recently.  I've made no major changes.  I've ran a diagnosis on my back up drive with no problems.  The Time Machine back up starts, but about after about 5 to 10 minutes I get the error message.  I can see the shared drive in Finder.  The light on the drive blinks while it starts the back up.  I can see the shared folders on the networked drive.  The backup process starts but for some reason it just stops.  Can anyone help?

    You can't repair a network volume in Disk Utility.
    Backing up to a third-party NAS with Time Machine is risky, and unacceptably risky if it's your only backup. I know this isn't the answer you want, and I also know that the manufacturer says the device will work with Time Machine, and that it usually seems to work. Except when you try to restore, and find that you can't.
    If you want network backup with Time Machine, use as the destination either an Apple Time Capsule or an external hard drive connected to another Mac or to an 802.11ac AirPort base station. Only the 802.11ac base stations support Time Machine, not any older model.
    If you're determined to keep using the NAS for backup, your only recourse for any problems that result is to the manufacturer (which will blame Apple.)

Maybe you are looking for