Solved

Sample JSP code to create a folder

Posted on 2003-11-27
4
516 Views
Last Modified: 2011-10-03
Dear Experts,

       I am facing a problem on how to create a folder by using JSP code. Can you please give me a hint on this? Thank you.

Regards,
   Jocelyn
0
Comment
Question by:jocelynyip
  • 3
4 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 9830668
<%
  File f = new File( "/path/to/folder/you/want" ) ;
  f.mkdirs() ;
%>
0
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
ID: 9830689
sorry:

 <%
  java.io.File f = new java.io.File( "/path/to/folder/you/want" ) ;
  out.println( f.mkdirs() ? "Folder created" : "Create failed!" ) ;
%>
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9830704
Or for those of us who despise the ?: operator and prefer readability ;-)

<%
  java.io.File f = new java.io.File( "/path/to/folder/you/want" ) ;
  if (f.mkdirs())
  {
    out.println("Folder created");
  }
  else
  {
    out.println("Create failed!") ;
  }
%>

(It does the same thing, give Tim the points ;-))
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9830750
>  Or for those of us who despise the ?: operator and prefer readability ;-)

Hehehehe....that was a simple one ;-)  the perfect case for the "?" operator :-)

it's when you start nesting them that readability becomes an issue...

    int i = (int)( Math.random() * 5 ) ;
    out.println( "i is " + ( i == 0 ? "zero" : i == 1 ? "one" : i == 2 ? "two" : i == 3 ? "three" : i == 4 ? "four" : "bigger than four" ) ) ;
0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
reflections, dynamic class loading 3 79
equalIsNot  challenge 43 178
print map entry 34 75
maven disable workspace resolution 1 37
Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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