проблема вознимает при записи строк из input'ов в textarea. Сразу же после внесения значений в textarea(это выполняет метод foo()) у меня идет заполнение этого же textarea(считывание из файла на сервере) и все локальные изменения в textarea сбрасываются, как сделать так, чтобы значения не сбрасывались?
<jsp:directive.page language="java" pageEncoding="utf-8"/>
<%@ page import="java.io.*" %>
<%@ page import="java.net.URL" %>
<!DOCTYPE html>
<html>
<head>
<script>
function foo(){
var x = document.getElementsByTagName("input");
for(var i = 0; i < x.length; i++) {
document.getElementById("textForPushOnServer").innerHTML += x[i].value;
}
}
</script>
<script>
function WriteToFile() {
<%
if(request.getParameter("applyChange") != null){
try{
FileWriter writer = new FileWriter(path, false);
String updURL = request.getRequestURL().toString().replace("mytools.jsp","") + "logconfig";
writer.write(request.getParameter("textForPushOnServer"));
writer.flush();
writer.close();
response.sendRedirect(updURL);
}catch(Exception e){
out.println(e.getMessage());
}
}
%>
}
</script>
<%!
public final String path = System.getProperty("user.dir") + "/log.properties";
%>
</head>
<body>
<form name="for">
<b>Input class name</b>
<input type="text" name="classname" id="classname" size="40">
<b>Input a name of logfile</b>
<input type="text" name="logfilename" id="logfilename" size="40">
<select name="nubexSelect" size="1">
<option disabled selected>Choose Log Level</option>
<option>ALL</option>
<option>DEBUG</option>
<option>ERROR</option>
<option>FATAL</option>
<option>INFO</option>
<option>OFF</option>
<option>TRACE</option>
<option>WARN</option>
</select>
<button type="submit" name="prep" onclick="foo();">Prepare</button>
<textarea name="textForPushOnServer" id="textForPushOnServer" style="width:80%" rows="33">
<%
try(FileInputStream fin=new FileInputStream(path)) {
int i =- 1;
while((i = fin.read()) != -1) {
out.print((char)i);
}
}
catch(IOException ex) {
out.println(ex.getMessage());
}
%>
</textarea>
<button type="submit" name="applyChange" onClick="WriteToFile();">Submit</button>
</form>
</body>
</html>
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости