Answer the question
In order to leave comments, you need to log in
How to output a .txt file line by line (not a whole array) to a JSP page without using php and ajax?
<%@page import="java.io.FileInputStream"%>
<%@page import="java.io.File"%>
<%@page import="java.io.InputStreamReader"%>
<%@page import="java.net.URL"%>
<%@page import="java.io.FileReader"%>
<%@page import="java.io.BufferedReader"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Read Text</title>
</head>
<body>
<link rel="stylesheet" type="text/css" href="../style/style.css" />
<div id="text">
<h4 id="c2">MONITORING</h4>
<a id="c1" href="<%=request.getContextPath()%>/LogoutUser">Выход</a>
<%
String txtFilePath = "C:/Users/Documents/config.txt";
String lineSeparator = System.getProperty("line.separator");
BufferedReader reader = new BufferedReader(new FileReader(txtFilePath));
//BufferedReader br = new InputStreamReader(new FileInputStream(txtFilePath));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
out.println(sb.toString());
%>
</body>
</html>
Actually, the question itself is indicated in the title, I’ll just clarify that there is an authorization page on GlassFish for a specific platform, there is a jsp page from which it is necessary to implement viewing config.txt and, in the future, editing. Browsing on JSP works, but it displays everything as a solid array, not line-by-line output, I have already broken my head.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question