Solved

jsp and files

Posted on 2004-04-30
9
156 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

12 Experts available now in Live!

Get 1:1 Help Now