Solved

jsp and files

Posted on 2004-04-30
9
162 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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

Why do some people recommend buying business VoIP from an ISP? What are the benefits to my company? What are the costs?
Let's recap what we learned from yesterday's Skyport Systems webinar.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

632 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