日期:2014-05-16  浏览次数:20631 次

jsp ajax页面间的传值问题
本帖最后由 showbo 于 2013-04-16 11:11:18 编辑
auto.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
     pageEncoding="ISO-8859-1"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>Insert title here</title>
 
 </head>
 <body>
  <% String a=request.getParameter("username");
     out.print(a);
  %>
 <Iframe name="frame1" id="frame1" src="au.jsp"; width="250" height="200" scrolling="no" frameborder="1"></iframe>
 </body>
 </html>


a.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
<script language="javascript"><!--  
var XMLHttpReq; 
function createXMLHttpRequest() {
     if(window.XMLHttpRequest) {  
      XMLHttpReq = new XMLHttpRequest();
     }
     else if (window.ActiveXObject) {  
      try {
       XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
       try {
         XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {}
      }
     }
}


var username ="aaaa";   
function sendReques() {
 createXMLHttpRequest();  
  var url = "auto.jsp?username="+username;
  alert(username);
  XMLHttpReq.open("get", url, true);
  XMLHttpReq.onreadystatechange = processResponse;// 
  XMLHttpReq.send(null);  //  
 } 
// --></script> 
</head> 
<body> 

 <form name=staffInput  >  
 <input type="button"  value="" onClick="sendReques()"/>
 </form>
 
</body> 
</html>

 


这样在auto.jsp页面中怎么接受不到传过来的值呢?刚接触ajax求助求助~~~~~~~~·

------解决方案--------------------
引用:
我想在父页面auto.jsp中得到由au.jsp传过来的值然后直接通过这个值查询数据库,然后把返回的数据库的信息直接在auto.jsp中输出而不是返回给au.jsp页面 , 这个能实现