Servlet에 JavaScript를 제출하는 5 가지 방법 :
/** 첫 번째 제출 방법**/function dopmentform1 () {wind form.action = "testservlet? param = formmethod"; form.submit ();}/***세 번째 제출 방법*/var xmlhttp; // xmlhttp function createxmlhttprequest () {if (wind } else {// IE6의 코드, ie5 xmlhttp = new ActiveXobject ( "microsoft.xmlhttp"); }} // ajax를 사용하여 function submitorform3 () {createxmlhttprequest (); var querystring = "testservlet2?"; QueryString = QueryString + "¶m =" + new Date (). gettime (); xmlhttp.onreadyStateChange = HandlestateChange; xmlhttp.open ( "get", querystring, true); xmlhttp.send (null); } // ajax는 post를 사용하여 function upplorform4 () {createxmlhttprequest (); var url = "testservlet2? param =" + new date (). gettime (); xmlhttp.open ( "post", url, true); xmlhttp.onreadyStateChange = HandlestateChange; xmlhttp.setrequestheader ( "content-type", "application/x-www-form-urlencoded"); xmlhttp.send ( "nihao");} function handlestatechange () {if (xmlhttp.readystate == 4) {// 반환 값을 if (xmlhttp.status = 200) {var responteetxt = document.createtextnode (xmlhtp.responsetext); ALERT ( "백그라운드에서 반환 된 반환 값 :"+XMLHTTP.RESPONSETEXT); }}} /** 다섯 번째 메소드 포스트 제출*@param to*@param p* /function dopmentform5 () {var myform = docum myform.method = "post"; myform.action = "testservlet"; myform.style.display = "none"; for (var k in params) {var myInput = document.createElement ( "input"); myInput.name = k; myInput.value = params [k]; myform.appendChild (myInput); } document.body.appendChild (myform); myform.submit (); //document.body.removechild(myform); myform;} 반환Servlet에 JSP를 제출하는 6 가지 방법 :
<%@ page language = "java"contmenttype = "text/html; charset = utf-8"pageencoding = "utf-8"%> <! doctype html public "-// w3c // dtml 4.01 Transitional // en" "http://www.w3.org/tr/tr/html4/loose.dtd"> html> <<<<<<<! charset = utf-8 "> <title> 제목 삽입 제목 </title> </head> <body> <!-메소드 1-> <%-<% requestDispatcher rd = getServletContext (). getRequestDispatcher ("/treadservlet? param = method one "); rd.forward (요청, 응답);%>-%> <!-메소드 2-> <%-<%response.sendRedirect ( "testservlet? param = method two");%>-%> <!-메소드 3-> <%-<jsp : 전달 페이지 = "testservlet? param = method 3"/>-%> <!-메소드 5- <%int ur urter = " 5 "; String Content = Staytime+"; url = "+url; response.setheader ("새로 고침 ", 컨텐츠);%>-%> <!-메소드 6-> <%response.setstatus (httpservletresponse.sc_moved_permanely); 문자열 newlocation = "testservlet? param = method 6"; 응답 .Setheader ( "위치", Newlocation); %> </body> </html>