Solved

jsp and files

Posted on 2004-04-30
9
159 Views
Last Modified: 2011-09-20
Can someone tell me what im doing wrong here? It seems to execute sometimes and other times it does'nt, im lost as to whats wrong and its driving me up the wall. Logically its corrrect isnt it? The out.prints get executed fine according to the if statements but the file commands dont get executed.

<%
 
 String Approved = request.getParameter("Approved");
       if(Approved.endsWith("s"))
       {
       out.print("yes");
       File file = new File("\\dir\\);
       File dir = new File("\\dir\\newdir");
       boolean success = file.renameTo(new File(dir, file.getName()));
       }
       else if(Approved.endsWith("o"))
       {
         out.print("no");
         File file1 = new File("\\dir\\);
         File dir1 = new File("\\dir\\newdir\\");
         boolean success = file1.renameTo(new File(dir1, file1.getName()));
       }
       else {}
          
%>
0
Comment
Question by:CrshUndrPrsre
9 Comments
 
LVL 32

Expert Comment

by:ldbkutty
ID: 10964188
>> File file = new File("\\dir\\);

should be:

File file = new File("\\dir\\");
0
 

Author Comment

by:CrshUndrPrsre
ID: 10964218

Thanks but its still not working
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10964494
what do you hope to accomplish with these file commands?
Ghost
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:CrshUndrPrsre
ID: 10964579

>>File dir1 = new File("\\dir\\newdir\\");
in second if

Should be
>>File dir1 = new File("\\dir\\newdir1\\");

Im just moving the files from one directory to another.
0
 

Author Comment

by:CrshUndrPrsre
ID: 10964733


Ive solved it!!

using this:

 while(!success)
         success = file.renameTo(new File(dir, file.getName()));
     
Thanks for your help, ive requested a points refund.
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10964756
glad you fixed it.
Cheers,
Ghost
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10968442
No objections here,
Ghost
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 10999804
Closed, 50 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are looking at this article, you have most likely been hit by some version of ransomware and are trying to find out if there is anything you can do, or what way you should react - READ ON!
ConnectWise and their customers need to ensure critical alerts automatically reach the right person at the right time. MSP superheros efficiently respond to these alerts key is providing automatic, intelligent alerting that generates a complete audi…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question