Mike R.
asked on
Design .jsp (or other) to dynamically create page based on items found in directory
Hey Gang,
I am a Solaris admin, but not a web designer (have had a little experience...very little.)
We are running Apache 2.0.35 on Solaris 5.8.
I would like to create a page (.jsp, or whatever) that dynamically looks at the list of items within the “../htdocs/subdir” directory within Apache, and creates a page on the fly with those items as links to that file/dir.
The reason being is, we want to be able to have scripts copy directories full of “txt” documents into “../htdocs/subdir” without us having to hand re-write the web page with the links.
I.E...
# ls ../apache2/htdocs/servers
serv1 (dir)
myserv (dir)
document.txt
differentDoc.html
Webpage****
Hi! Welcome to the admin webpage! Click any of the links below...
serv1
myserv
document.txt
differentDoc.html
...and clicking differentDoc.html brings up that page, clicking document.txt brings up that doc, and clicking on the link for serv1 or myserv just takes you into that dir (the subdir does not need formatting, per se’-as it will just be .txt docs the person can click on.)
A million thanks
Mike
I am a Solaris admin, but not a web designer (have had a little experience...very little.)
We are running Apache 2.0.35 on Solaris 5.8.
I would like to create a page (.jsp, or whatever) that dynamically looks at the list of items within the “../htdocs/subdir” directory within Apache, and creates a page on the fly with those items as links to that file/dir.
The reason being is, we want to be able to have scripts copy directories full of “txt” documents into “../htdocs/subdir” without us having to hand re-write the web page with the links.
I.E...
# ls ../apache2/htdocs/servers
serv1 (dir)
myserv (dir)
document.txt
differentDoc.html
Webpage****
Hi! Welcome to the admin webpage! Click any of the links below...
serv1
myserv
document.txt
differentDoc.html
...and clicking differentDoc.html brings up that page, clicking document.txt brings up that doc, and clicking on the link for serv1 or myserv just takes you into that dir (the subdir does not need formatting, per se’-as it will just be .txt docs the person can click on.)
A million thanks
Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey Gang,
Sorry about all the delays. As it turns out, I am being forced to re-allocate this server to a different function...so I am going to have to start the process over.
I am going to assign points since I think you gave me what I need to know...I just need to test it. I will resubmit another question if i run into more snags!
Thanks for the help and the patience!!
Sorry about all the delays. As it turns out, I am being forced to re-allocate this server to a different function...so I am going to have to start the process over.
I am going to assign points since I think you gave me what I need to know...I just need to test it. I will resubmit another question if i run into more snags!
Thanks for the help and the patience!!
new version of ls.jsp
--------------------------
<%@ page import="java.io.*, java.util.*" %>
<html>
<head><title>list files and directories</title>
</head>
<body>
<%
String currentLocation = getServletContext().getRea
String[] arDirs = new File(currentLocation).list
Arrays.sort(arDirs) ;
for( int ii=0 ; ii<arDirs.length ; ii++){
File file = new File(currentLocation + arDirs[ii]) ;
String type = file.isFile() ? " <file>" : " <dir>";
out.println( "<a href='"+arDirs[ii]+"'>"+ arDirs[ii] + type +"</a><br>") ;
}
%>
</body>
</html>