Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

Sample JSP code to create a folder

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
jocelynyip
Asked:
jocelynyip
  • 3
1 Solution
 
TimYatesCommented:
<%
  File f = new File( "/path/to/folder/you/want" ) ;
  f.mkdirs() ;
%>
0
 
TimYatesCommented:
sorry:

 <%
  java.io.File f = new java.io.File( "/path/to/folder/you/want" ) ;
  out.println( f.mkdirs() ? "Folder created" : "Create failed!" ) ;
%>
0
 
jimmackCommented:
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
 
TimYatesCommented:
>  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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now