我想将画布转换为图像并将该图像发送到我的服务器。所以我想要的是使用javascript从html页面收集画布,然后将该数据发送到我的servlet,我可以在服务器上执行上传图像。
谢谢......Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Request header is too large
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:701)
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:455)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:667)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
function saveImg() {
var canvasData = document.getElementById("myCanvas").toDataURL("image/png");
alert(canvasData);
var xmlhttp = new XMLHttpRequest();
var url = "Signature?image=" + canvasData;
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState === 4 && xmlhttp.status === 200){
var response = xmlhttp.responseText;
response = response.replace(/\r?\n|\r/g, " ");
response = response.trim();
if(response === "Bill Receipt sent successfully"){
alert("Bill Mailed Successfully");
}
else{
alert("Something's not good please contact the admin");
}
}
};
try{
xmlhttp.open("GET",url,true);
xmlhttp.send();
}catch(e){alert("unable to connect to server");
}

public class Signature extends Canvas {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String image = request.getParameter("image");
System.out.println(image);
}
}