Sample JSP code to create a folder

Posted on 2003-11-27
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.

Question by:jocelynyip
  • 3
LVL 35

Expert Comment

ID: 9830668
  File f = new File( "/path/to/folder/you/want" ) ;
  f.mkdirs() ;
LVL 35

Accepted Solution

TimYates earned 50 total points
ID: 9830689

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

Expert Comment

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

<% f = new "/path/to/folder/you/want" ) ;
  if (f.mkdirs())
    out.println("Folder created");
    out.println("Create failed!") ;

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

Expert Comment

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" ) ) ;

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
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…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

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

14 Experts available now in Live!

Get 1:1 Help Now