Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2012, 09:49 PM   PM User | #1
misteng
New to the CF scene

 
Join Date: Feb 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
misteng is an unknown quantity at this point
Internet Explorer Use Java to list files in a directory and then full into an iframe>

Hello and thank you in advance for your time!
I am building a page that will display a file in an iframe.
The problem is that the files won't necessarily be static.
We are collecting weather data at 1 min. intervals which is saved into a flat file. I will be uploading these files (and re-uploading at set intervals) into a set directory with a naming scheme of Feb12log.* (type of file doesn't really matter. could be .txt, .csv, .xls) but the name will change corresponding with the month & year: {MMM}{DD}log.{ext}. Each month, a new file is created
I can successfully pull a file into an iframe. I can build a drop box and a static list of files (File1, File2, File3 etc). I am pretty sure that I can build a search box in the page that will parse the information in the iframe (Ctrl+F would work as well I guess). Hopefully this is enough background info.
Instead of building a page for each new month ad nauseam, I would love to be able to pull a list of files currently in the upload directory into a dropdown box and when a file is selected, have it display in an iframe on the same page. The ability to be able to search the page would be awesome.

I am not looking for a handout, and I appreciate any input at all. My questions are: 1. Is this possible? Or should I resign myself to manually creating new pages every month? 2. Would anyone be able give me a nudge in the correct direction?
Thanks again!
M
misteng is offline   Reply With Quote
Old 02-03-2012, 07:44 PM   PM User | #2
misteng
New to the CF scene

 
Join Date: Feb 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
misteng is an unknown quantity at this point
I'm slowly making progress.

So I can pull a drop down from an array:

Code:
<script language="javascript">

function optionSel(selectbox,text,value )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
}

function Option_list(selectbox){
var month = new Array("Jan12","Feb12","Mar12","Apr12","May12","Jun12","Jul12","Aug12","Sep12","Oct12","Nov12","Dec12");
for (var i=0; i < month.length;++i){

optionSel(document.drop_list.Month_list, month[i], month[i]);
}
}
</script>
</head>

<body onLoad="Option_list()";>
	<FORM name="drop_list" action="yourpage.php" method="POST" >
		
		<SELECT  NAME="Month_list">
			<Option value="" >Month list</option>
		</SELECT>
	</form>
</body>
And I have figured out how to pull multiple links into a target iFrame:

Code:
<html>
<head>
<TITLE>Site Current Month Totals</TITLE>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</HEAD>
<TABLE ALIGN=Left BORDER=1 BGCOLOR="#80FF00">
<TR>
<TD><H4>Monthly Totals</H4>


<UL>
<LI><A HREF="Jan12log.txt" TARGET="DisplayWindow">Document 1</A>
<LI><A HREF="Feb12log.txt" TARGET="DisplayWindow">Document 2</A>
<LI><A HREF="Mar12log.txt" TARGET="DisplayWindow">Document 3</A>
</UL>

<IFRAME 
    SRC="VerCurMonth.htm"
    NAME="DisplayWindow"
    WIDTH=1024 HEIGHT=480>
</IFRAME></TD>
</TR></TABLE>
		
</BODY>
</HTML>
Does anyone have an idea for code for a recursive search that can read a directory into an array? It could be a server side script.
If I can figure that out, and figure how to tie it all together, the only thing left is to format the directory list as links and it should be good.
Thoughts?
Again, I would be very thankful for any tips.
M
misteng is offline   Reply With Quote
Old 02-07-2012, 01:35 PM   PM User | #3
misteng
New to the CF scene

 
Join Date: Feb 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
misteng is an unknown quantity at this point
Anybody Have any thoughts?

I apologize for the bump.
misteng is offline   Reply With Quote
Old 02-07-2012, 05:21 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Are you sure your language in use here is Java? all of the code you have here is Javascript and the processing language is PHP. If the file scan is on the server, this given the code you have, would be a PHP task. If its local, it would be Javascript, but I don't know what type of control there is in place to prevent iteration of filesystem (I'd guess that it would be denied local).

If its Java, I'm not sure how much help you'll find here. Unfortunately, I'm am probably among the more versed in JSP, and I haven't used it in over 6 years with no intention of ever touching it again.
Fou-Lu is offline   Reply With Quote
Old 02-07-2012, 06:05 PM   PM User | #5
misteng
New to the CF scene

 
Join Date: Feb 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
misteng is an unknown quantity at this point
@Fou-Lu,
That was a mistype in the title.
Truly, I am not picky on what language or process that is used to get the desired results. Thus far I am just piecing together snippets that I have found on the web.
The restraints can be as liberal as needed. (it is a local iis 7 server on an intranet, which is used to display weather data) Although I would like to keep close to best practice on the security side, I am willing to loosen as needed to get this done.
Any thoughts on how it might be accomplished (in any language)?
Thank you in advance.
misteng is offline   Reply With Quote
Old 02-07-2012, 08:58 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Pretty much any language is capable of scanning a directory. Reading on a client cannot be done without a client language, and reading from a server takes a server language. I'd bet that JS itself could not read the filesystem of the client. Java itself can have an app written to perform this task. If its already on the server, then your processing language there would scan and show as necessary.
Web processing languages job is to dynamically generate content from either changing information or from user input. So sure you can set this up to do what you want. But you do need to choose the language you are planning to use first; JSP requires a JSP compatible server, ASP.NET would require IIS, PHP is pretty much fair game anywhere as is Perl. All of these languages can iterate a directory and choose files if you provide it something to compare against so long as they are on the server itself.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
directory, file, iframe, java, list

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:03 AM.


Advertisement
Log in to turn off these ads.