<div></div> reads .txt file

I need a way to make a div on my html page to read an external txt file.
I found loads of solutions using Java but nothing seems to work.

help :(
LVL 1
zahimezherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nenad RajsicCommented:
try this:
<iframe name="FRAME1" src="robots.txt" width="350" height="360" frameborder="0" ></iframe>
0
zahimezherAuthor Commented:
i cant use iframe. it has to be a div. i have no idea why but the team leader wants a div :S
0
StealthyDevCommented:
what is the server script you are using? VB/Java?
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

zahimezherAuthor Commented:
java
0
StealthyDevCommented:
Try with the code attached.

<%@page import="java.io.*"%>

<%
	BufferedReader input = new BufferedReader(new FileReader("TestFile.txt"));
	String line = "";
	while ((line = input.readLine()) != null) {
		out.println(line);
	}
	input.close();
%> 

Open in new window

0
StealthyDevCommented:
Please find the updated code into div tag:

<%@page import="java.io.*"%>

<%
	BufferedReader input = new BufferedReader(new FileReader("TestFile.txt"));
	String line = "", fullFile = "";
	while ((line = input.readLine()) != null) {
		//out.println(line);
		fullFile += line + "<BR>";
	}
	out.println("<div>" + fullFile + "</div>");
	input.close();
%> 

Open in new window

0
zahimezherAuthor Commented:
didnt work on my machine so i tried uploading. the code showed on the html page.
my server is php based
0
StealthyDevCommented:
Then use this?

$myFile = "testFile.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, 5);
fclose($fh);
echo $theData;

Open in new window

0
StealthyDevCommented:
This should work perfectly.

<div>
<?php
$fh = fopen("myfile.txt", "r");

$file = file_get_contents("myfile.txt");
echo $file;
?>
</div>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.