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
Solved

Sample JSP code to create a folder

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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