Hello good afternoon friends,
I have created a project that I was asked for a job that I applied for and they asked me to make the contents of a .txt file appear in an html. I already have something advanced in the code that I found, it works and you can see it from the same html (jsp), here the problem is that I do not know how to do it in a page, that is to say that I do not throw all the content but 20 in 20 by means of the bar, something similar as when we look for something in Google, since the records are more than 40,000 and that such records are displayed as a type.
This is the code that already works and is in javascript:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
window.onload=function(){
function leerArchivo(e) {
var archivo = e.target.files[0];
if (!archivo) {
return;
}
var lector = new FileReader();
lector.onload = function(e) {
var contenido = e.target.result;
mostrarContenido(contenido);
};
lector.readAsText(archivo);
}
function mostrarContenido(contenido) {
var elemento = document.getElementById('contenido-archivo');
elemento.innerHTML = contenido;
}
document.getElementById('file-input')
.addEventListener('change', leerArchivo, false);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1>Hola mundo</h1>
<input type="file" id="file-input" />
<h3>Contenido del archivo:</h3>
<pre id="contenido-archivo"></pre>
</body>
</html>
This is how it looks like:
I hope and that more or less can give me to understand and help me with this please, I remain on the sidelines if there is something that is not understood, greetings and good vibes.