getSomethingWithAjax を使用して送信されたデータにはブラウザーの制限があります。大きなデータを投稿したい場合、 getSomethingWithAjax() を代用するものは何でしょうか? ここに私のコードがあります: このコードは textarea でテキスト ファイルを開き、ユーザーが文字を入力または削除できるようにします。約 2800 文字を超える送信には制限があります。
<%
if(request.getParameter("thetext") != null) {
File savedHere = new File(request.getParameter("filepath"));
FileOutputStream out2 = new FileOutputStream(savedHere);
PrintStream p = new PrintStream(out2);
try {
boolean gotError = false;
if(request.getParameter("revert").equals("1")) {
System.out.println("In revert");
p.print(request.getParameter("thetextRev").replace("\r",""));
gotError = p.checkError();
p.close();
} else {
System.out.println("NOT in revert\n"+request.getParameter("thetext"));
p.print(request.getParameter("thetext").replace("\r",""));
gotError = p.checkError();
p.close();
}
if(request.getParameter("revert").equals("0")) {
if(!gotError) {
out.println("File was successfully modified");
} else {
out.println("Error while writing the file");
}
}
}
catch(Exception ex) {
System.out.println("Exception while trying to write out to file");
out.println("There was an error while writing file");
}
}
String filename = "";
java.lang.StringBuffer myStuff = new java.lang.StringBuffer(100000);
if(request.getParameter("STEP")!=null
&& request.getParameter("secret")!=null
&& !request.getParameter("secret").equals("yes")) {
filename = request.getParameter("autoFiles");
File chosenFile = new File(filename);
DataInputStream dis = new DataInputStream(new FileInputStream (chosenFile));
String data = null;
while((data = dis.readLine()) != null) {
myStuff.append(data+"\n");
}
//this is just to check capacity and current length of file
out.println("Capacity is:"+ myStuff.capacity()+ "characeter count is" +
myStuff.length());
%>
<br>
<form method="POST" class="example" action="/jsp/EditText.jsp" id=form2>
<input type=hidden name=filepath value="<%=filename%>">
<input type=hidden name=revert id=revert value="0">
<input type=hidden name=textarea value=true>
<br>
<center>
<textarea class="form-textarea resizable" id="textarea" style="width:90%;height:27em;
font-family:courier;font-size:14;"
name="thetext"><%=myStuff.toString()%></textarea>
<div style="display:none;">
<textarea id="textareaRev" style="width:90%;height:27em; font-family:courier;font-
size:14;"name="thetextRev"><%=myStuff.toString()%></textarea>
</div>
<br><br>
<input type=button name=submit value="Save Changes"
onClick="if(runOnSubmit(){
getSomethingWithAjax('EditText.jsp'+
getAllFormElementsAndMakeIntoURI(true),'','hereIsTheMainHeaderSpan',false,false);}">
<input type=button name=submitRev value="Cancel/Exit"
onClick="toggleTextRevert();
getSomethingWithAjax('EditText.jsp','','hereIsTheMainHeaderSpan')">
<%
} else {
//initial part here, not relevant
/*
this part sorts a list of files located in a specific directory in a
dropdown menu Auto files is the generated files from the dropdown menu
*/
}
%>