Java/JSP app to List Directories in a Drop Down

Hi all! I'm a Java Newbie and have an application that was written in VB / ASP that I need to convert to Java / JSP. The app is relatively simple, however my understanding of Java is even more basic. :(
Here's what I need... The app needs to be able to read a directory structure on the web server and populated a drop down box on a JSP with the directory names. Then when one of the directories that are in the drop down are selected, the files within that directory are listed as HTML links to the actual files.
How do I get started?? Any sample code from people who have done this??
Thanks!
Teresa

Basically what you want to do is build a vector of objects that represent directories, and each "directory" object contains a vector of files as an attribute. This is done on the server side in a Servlet.
Then store all these objects in your session. Dynamically build your dropdown box to have an element for each directory. Use the JavaScript onSelect method to invoke another JSP that takes the number of the element selected, and displays all html links for the number that was passed in from the previous servlet.
For some about $150 I would write the whole thing for you, but here would be the server side code that builds a recursive directory list.
import java.io.*;
import java.util.*;
public class RecursiveDirectoryList {
     Vector Directories = new Vector();
     Vector Files = new Vector();
public RecursiveDirectoryList() {
     super();
public static void main(String[] args) {
String directoryName; // Directory name entered by the user.
File directory; // File object referring to the
//directory.
//TextIO.put("Enter a directory name: ");
directoryName = "C:\\docs";
directory = new File(directoryName);
if (directory.isDirectory() == false) {
// Program needs a directory name. Print an error message.
if (directory.exists() == false)
System.out.println("There is no such directory!");
else
System.out.println("That file is not a directory.");
else {
// List the contents of directory, with no indentation
// at the top level.
listContents( directory, "" );
} // end main()
static void listContents(File dir, String indent) {
// A recursive subroutine that lists the contents of
// the directory dir, including the contents of its
// subdirectories to any level of nesting. It is assumed
// that dir is in fact a directory. The indent parameter
// is a string of blanks that is prepended to each item in
// the listing. It grows in length with each increase in
// the level of directory nesting.
String[] files; // List of names of files in the directory.
System.out.println("Directory: " + dir.getAbsolutePath());
indent += " "; // Increase the indentation for listing the contents.
files = dir.list();
for (int i = 0; i < files.length; i++) {
// If the file is a directory, list its contents
// recursively. Otherwise, just print its name.
File f = new File(dir, files);
if (f.isDirectory())
listContents(f, indent);
else
System.out.println("File: " + dir.getAbsolutePath() + "\\" + files[i]);
} // end listContents()

Similar Messages

  • AccessDenied Error deploying Java JSP app using Eclipse to Azure

    Hi,
    Following the the tutorial for deploying java servlet app on Azure using Eclipse on windows.
    Getting AccessDenied error while trying to upload, sample works locally.
    Thanks
    Raj

    Hi Raj,
    Which tutorial do you follow? Please have a look at below article, it gives details steps about how to deploy application to azure use Eclipse, please try again step by step, hope this helps.
    #http://msdn.microsoft.com/en-us/library/azure/hh690944.aspx
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Followed video about burning my completed movie to a DVD and iDVD was not listed in the sharing drop down. What gives?

    Why wasn't iDVD listed in sharing drop down when trying to burn DVD?

    Hi
    If there is no iDVD on Your Mac (and it's not on newer Macs as Apple discarded it) then You need a program that can do this.
    Your Mac can burn CDs and DVDs - BUT DVD as Data-DVDs not as Video-DVDs - they need a program to be encoded and STRUCTURED as such.
    • iDVD is part of the boxed version of iLife'11 and can only be bought outside Apple as on Amazon and e-bay
    • DVD Studio pro - Part of FinalCut Studio Pro bundle - this to has expired and can only be bought second handed. (High price and tough learning Curve - but best ever done.)
    • Roxio Toast™ - Not as elegant as iDVD - but has many other positive additions (I like it as 10-Pro incl BD-component) (now version 11)
    • Burn - only free alternative I know of on internet. Very simple - Just for doing a plain Video-DVD
    Burn http://www.digital-digest.com/software/Burn.html
    only You can buy from Apple is
    • FinalCut Pro-X which also can burn to DVD but without any nice themes.
    AppleMan1958
    You can also buy Compressor from Apple for $50 US. It will also create DVD and BluRay but without the nice themes.
    Yours Bengt W

  • Auto-populating Infopath fields from a Sharepoint list after selecting a drop down

    I currently have two lists one titled 'Book of Work' which holds details around on-going projects and the other titled 'Book of Work Amendments' which are requests submitted by users to change project details (through an infopath form).
    There is a column in the BoW Amendments list entitled 'Select Project' which has a lookup to 'Project Name' in the BoW list. The aim is that when a user chooses an option from the 'Select Project' drop-down, other fields in the form such as 'Project Manager',
    'Project Description' will be automatically populated with data from that row in the BoW table.
    I have connected both Sharepoint Lists as data connections with BoW Amendments being the primary and BoW the secondary. If we take the Project Manager field as an example the method I have attempted is as follows:
    . Create a rule with condition Select Project is not blank
    . Action - Set a field's value: Field: Project Manager (BoW Amendments - Primary) Value:
    Project Manager (BoW - Secondary) Add Filter: Project_Name (BoW - Secondary) =
    Select Project (BoW - Primary)
    Currently this is not populating the field when the project is selected in the drop down, any assistance would be greatly appreciated.

    Hi Josh,
    This should be straight forward. You do not need BOW Amend data connection. You are creating requests in this list so this will be your Main Data Connection.
    When creating the rule on the drop down, select Action:
    Condition: anytime the value changes, Set a field's value - Project Manager (Main); Value - Project Manager(BOW) where Project[BOW] = Project [Main]
    Hope it helps.
    Regards, Kapil ***Please mark answer as Helpful or Answered after consideration***

  • Font not found when opening file and not able to resolve, but is listed in the fonts drop down list?

    Hi, i just downloaded some files from a friend and he sent me a link to download the fonts. I did so and 98% of the fonts work, but there are two fonts i am struggling with.
    When i open the file i get the font missing warning and it asks me to resolve the fonts. I cannot find the appropriate font in the drop down list so i click 'don't resolve' and start to edit the file. i then come across some text that has missing fonts and i am able to highlight the text and change the text to the appropriate font using the type tool and the font I am looking for is in the drop down list.
    The fonts that aren't working are:
    Franchise Bold and BebasNeue
    The problem is there are multiple separate incidents where these fonts occur, and going through changing each one manually would take a lot of time.
    Is there something i can do to fix them all at once?
    Thanks,
    Harry

    I do not see either font  in the list you show.  I see Bebas Neue xxx but no Bebas Neue without any extra style. Try Bebas Neue at Download Bebas Neue Font - Thousands of fonts to download for free

  • Related Issue column in tracking list gets changed into drop down list in Infopath

    Hi All,
     i have created Tracking list in sharepoint 2010. which has column[Related issue - lookup for field in list[title] by default.
    this field will have a multiple selection check box,2 buttons [Add and remove] and text box[which show the items selected in check box].
    my issue is ,when i try to modify my list in Infopath. this column[Related issue] gets changed into drop down list item.Is is possible  to get the same [old format] back. if so pls guide me..
    I faced the same in Radio button,but i restored it by changing it into option button in Infopath
    V Jean

    Hi ,
    The
    multiple-selection list box control should be by design in InfoPath form, which is corresponding to the SharePoint "Related Issues" field, in my opinion, it cannot be converted to [old format] in InfoPath form, you may need to use SharePoint Designer 2010
    to customize your Issue Tracking list NewForm.aspx/EditForm.aspx per the way in the following article, then "Related Issues" field will still be the old format,
    http://www.cjvandyk.com/blog/Articles/How%20do%20I%20-%20Customize%20the%20NewForm.aspx%20or%20EditForm.aspx%20of%20my%20SharePoint%20list.aspx
    Thanks
    Daniel Yang
    TechNet Community Support

  • Is there a way to right click - open in new tab on the list of recent pages drop down menu?

    I know that I can get the same effect by opening a new copy of the current page in a new tab and then back pedaling to the earlier page, but that is a bit cumbersome.

    There is no Contextual menu for the Location bar drop-down, so you need to use {Ctrl + Click} or Middle-click the item to have browsing history items load in a new tab.

  • Displaying something other than a list in a JComboBox drop down section

    Dear all,
    i'd like to be able to put a JTree into a JComboBox drop down section, or at least appear to have done this. has anyone done this or have an idea how this might be achieved?
    Cheers,
    Matt

    Sounds like a job for a custom renderer. The JTree tutorial shows an example of one.

  • I accidently typed in my password as my username on my gmail account. now when I go to login, my password is an option listed on the username drop down list. How can I remove it from this list?

    I've already tried going to tools-options-privacy-delete cookies. It did not work.

    See [[Remembering passwords]], you can turn this feature off.
    You also can [[Remembering passwords#Viewing and deleting passwords|view or delete the saved passwords]].
    Please let us know whether that works for you.

  • Need help Setting Up Existing JSP app

    I just downloaded release 2 to get a look and see if it's time to make the switch (currently using an old version of JBuilder).
    I have an application built with JSP's with an existing directory structure. What I'd like to do is import the structure into a project so that the files are available and the includes are picked up. Currently when I'm looking at one of the JSP's (main.jsp) which has a reference to an include I'm getting an error that it can't find the include file. The include looks like:
    <%@ include file="/app/include/navbar_images.jsp" %>
    I've tried to set the project src path to D:\java\jsp (which is where the app directory from the above include lives). This doesn't seem to solve the problem.
    The file I'm working with lives in D:\java\jsp\app\main by the way.
    Can someone point me in the right direction?

    Make sure to set your "html source directory" to D:\java\jsp\. By doing so, you can reference all your
    files by a uri relative to your "html source directory".

  • Populate drop-down list from multiple text fields.

    Just to begin, I am brand new to this application and brand new to coding in general. Anyways, this is what I am trying to accomplish. I need to populate a drop-down list from multiple text fields. I am able to populate one item using this in the calculate event:
    TextField1.rawValue
    After I type text in TextField1 and hit enter, it displays the text in the drop-down list. I need to do this but with more than just one text field to populate more options for the drop-down list. I will also need to do something similar with populating a drop-down list from selections made in multiple other drop-down lists.
    Thanks for any help you can give me.

    Thank you for your suggestion Geo Kaiser. With that, I was able to populate my drop-down lists, but now when I select an option from the drop-down list, the selection dissapears. The selection will appear briefly in the box but then dissapears although my drop-down list options remain there. Here is the code I am using for my text field to drop-down list:
    DropDownList1.clearItems()
    DropDownList1.addItem(TextField1)
    DropDownList1.addItem(TextField2)
    And here is my code for my drop-down list to populate another drop-down list:
    DropDownList3.clearItems()
    DropDownList3.addItem(DropDownList1)
    DropDownList3.additem(DropDownList2)
    Thanks again for your help. By the way, I am using Adobe Designer 7.0.

  • Drop down lists in Service Manger ConsoleForm

    I am trying to add 2 fields to the ConsoleForm.
    I have figured out how to customize the form itself, but I can't seem to get the field to work the way that I want.
    I want the user to select a field from one drop-down, and then based on their selection, select from different lists in the second drop-down.
    Any insight would be greatly appreciated.

    Properties are intended to be independent, so there are no default links like the ones you describe. an example of this is Urgency and Impact. both  are independent data, that is, something can be high urgency and low impact.
    Sub-category data is typically handled by a multi-level Enum, like Service Request Area. it makes sense to have a Facilities\Power issue, but a Content\Power issue isn't very meaningful. 
    you can do this by making your data type a List, then adding child items using the console List view. 
    Alternatively, you could create a custom control, but that would be a lot of C# code work.

  • Dynamic Drop-down list - selected value can't be cleared ...

    1. check out the following code of a dynamic drop down list using cursor :-
    DECLARE
         -- DROP-DOWN LIST OF ALL DEPARTMENTS
         TEMPNUMBER NUMBER(2) := 2 ;
    -- Because we've to initialize the list
    -- at least with 1 item.
    CURSOR C_DEPT IS
         SELECT DEPT_ID FROM DEPARTMENT;
    BEGIN
         ABORT_QUERY ;
         CLEAR_LIST('DEPTLIST');
         FOR TEMP IN C_DEPT LOOP
         ADD_LIST_ELEMENT( 'DEPTLIST', TEMPNUMBER, TEMP.DEPT_ID, TEMP.DEPT_ID );
         :SRBLOCK.LST := TEMP.DEPTNO;
         -- prev. line set the newly selected value
         TEMPNUMBER := TEMPNUMBER + 1 ;
         END LOOP;     
    END;
    2. problem is as we've to atleast initialize with one list item... that item can't be cleared with CLEAR_LIST.
    3. how can i actually clear that and still use cursor. because i've searched forum for this thing and found all those code not working ... for my project ...
    4. quick help needed ...

    Hi Omar,
    I have solution for you
    To populating or refreshing the lists you can use
    two procedures:
    One of them - generic, which can be used for all types of list
    Another is specific which contain a SQL statement to retrieve the data for
    particular list.
    1. Specific procedure:
    PROCEDURE GET_DEPARTMENT_LIST
    IS
    sql_stat VARCHAR2(32767);
    ret_code NUMBER;
    BEGIN
    -- SQL Statement for Drop-down List
    -- (must have two columns for label and value - both VARCHAR2)
    sql_stat := ' SELECT DEPARTMENT_NAME,TO_CHAR(DEPT_ID)'
    ||' FROM SCHEMA.DEPARTMENT';
    POPULATE_MY_LIST('BLOCK.DEPARTMENT_LIST',sql_stat,ret_code);
    END;
    2. Generic procedure:
    PROCEDURE POPULATE_MY_LIST
    (item_name VARCHAR2,
    sql_stat VARCHAR2,
    out_code OUT NUMBER)
    IS
    rg_id RECORDGROUP;
    rg_name VARCHAR2(100);
    ret_code NUMBER;
    item_id ITEM;
    BEGIN
         item_id := FIND_ITEM(item_name);
         IF ID_NULL(item_id) THEN
              out_code := -1;
              RETURN;
         END IF;
         --Creating Record Group with Unique Name
         rg_name := 'RG_'||SUBSTR(item_name,INSTR(item_name,'.',1)+1,LENGTH(item_name));
         --Checking Record Group Name for existance
         rg_id := FIND_GROUP(rg_name);
         --If Group does exist - delete it
         IF NOT ID_NULL(rg_id) THEN
              DELETE_GROUP(rg_id);
         END IF;
         --Creating Record Group
         rg_id := CREATE_GROUP_FROM_QUERY(rg_name,sql_stat);
    ret_code := POPULATE_GROUP(rg_id);
    IF (ret_code <> 0) THEN
         out_code := ret_code;
         RETURN;
    END IF;
    POPULATE_LIST(item_name,rg_id);
    IF NOT FORM_SUCCESS THEN
         out_code := -2;
         RETURN;
    ELSE
    out_code := 0;     
    END IF;
    DELETE_GROUP(rg_id);
    END;
    Hope it help.
    Dmitry

  • Linking two drop down list together

    I have two drop downs list and I need to link them together for the user to only answer one of them and it won't allow an answer in the other or vice versa. How can I set that up?
    If answer drop down list A then can't answer drop down list B
    else
    if drop down list B is answered then drop down list A can't be answered.

    The attached contains two drop-down lists - apples and oranges. Each drop-down list has a default list item value of " ", thus the default index is 0 (zero). If you select a value other than default, the other drop-down list has it's access protected and the list item reset to 0 (zero). Conversely, if you select the default value, the other drop-down list becomes open or accessible.
    // form1.page1.apples::exit - (JavaScript, client)
    if (form1.page1.apples.selectedIndex != 0) {
      form1.page1.oranges.access = "protected";
      form1.page1.oranges.selectedIndex = 0;
    else {
      form1.page1.oranges.access = "open";
    // form1.page1.oranges::exit - (JavaScript, client)
    if (form1.page1.oranges.selectedIndex != 0) {
      form1.page1.apples.access = "protected";
      form1.page1.apples.selectedIndex = 0;
    else {
      form1.page1.apples.access = "open";
    Steve

  • Adobe LiveCycle Designer working with 2 drop down list, one response triggers the other

    I am fairly new to Adobe LiveCycle Designer ES 8.2, but I would like to have a drop down list of managers and another drop down list of employees.
    I would like this set up in such a way where the manager can click on their own name in the manager list and have a drop down list appear which is only populated with their directly reporting employees.  They can then click on the individual employee they are going to report on.
    Then there will be several questions pertaining to the individual direct report, etc. (This part I can do)
    Is this possible?
    If so, please provide detailed instructions for me to try.
    Thank you in advance.

    Put this in the change event of your Manager drop down:
    var myObj={"Manager 1":"Employee A,Employee B,Employee C",
                        "Manager 2":"Employee D,Employee E",
                        "Manager 3":"Employee F,Employee G, Employee H"};
    DropDownList2.setItems(myObj[this.boundItem(xfa.event.newText)]);
    This is assuming the list of items in that dropdown is "Manager 1", "Manager 2", "Manager 3".
    And DropDownList2 is the name of your Employee drop down.
    Kyle

Maybe you are looking for

  • My itunes account wont let me download music

    i am trying to download my music from my itunes purchased but showes a message that i cant download my music until 90 days. what can i do?

  • Dual display preferences

    I have an 23" aluminum Apple display attached to my iMac. I do not have a way to control the brightness or on/off button like I did with my old G5 tower, either on the monitor or within the preferences. Is there any way to get these buttons back?

  • Limit number of employee photo's

    We are storing employee photo's in SAP via ArchiveLink. There is no problem with that. But..... We want to limit the number of photo's of an employee to two. I can't find any parameter or clue to do this. Anyone?

  • Safari stops connecting to secure sites

    My son is using Panther 10.3.9 and in Philadelphia using ComCast cable internet services. Everything was ok about a week ago... and he has done no security updates since. He is now unable to connect to secure websites for banking, etc. using Safari 1

  • Cannot change lock screen pin or to swipe

    Hi, I've just installed an app for my company wifi which requires the phone to have a lock screen. I chose a swipe pattern initially. After installation I wanted to change the pattern but the phone keeps asking me to enter the initial swipe pattern r