Solved

jsp and files

Posted on 2004-04-30
9
160 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
Adults who share images on social media aren’t the only ones who need to worry about their privacy. Our culture’s tendency to share every move and celebration affects the privacy of our children, too.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

740 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