Solved

Sample JSP code to create a folder

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
password protect pdf 11 76
IE doesn't Invoke servlet in iframe 1 111
withoutString  challenge 40 197
tomcat startup error 5 59
One of the biggest threats facing all high-value targets are APT's.  These threats include sophisticated tactics that "often starts with mapping human organization and collecting intelligence on employees, who are nowadays a weaker link than network…
Binary Differential Replication, What it is, how it works and how it differs from standard delta file replication
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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