Solved

jsp and files

Posted on 2004-04-30
9
157 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now