Solved

Sample JSP code to create a folder

Posted on 2003-11-27
4
517 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
[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
  • 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

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!

Question has a verified solution.

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

Suggested Solutions

Configuring Remote Assistance for use with SCCM
Unified and professional email signatures help maintain a consistent company brand image to the outside world. This article shows how to create an email signature in Exchange Server 2010 using a transport rule and how to overcome native limitations …
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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