这是我的代码
的index.html:
<html>
<head>
<script language="javascript">
var xmlHttp;
var f=1;
var t = "text";
function showState()
{
if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert ("Browser does not support XMLHTTP Request");
return
}
var url="additem.jsp";
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function stateChange(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById(t).innerHTML=xmlHttp.responseText;
t = "text"+f.toString();
f=f+1;
}
}
</script></head>
<body>
<center>
<form action=AddProd1.jsp method=post>
Enter Catagory <td><BLOCKQUOTE></BLOCKQUOTE><BLOCKQUOTE><center><input type=text name=catagory></BLOCKQUOTE></td>
</center>
<br><br>
<div id='text'></div><br>
<input type=submit value=Submit>
</form>
<input type=submit value=new onclick="showState();">
</body></html>
additem.jsp:
<jsp:useBean id="ob" class="te.tes" scope="session" />
<%!
String value = "";
String t = "" ;
String v="";
%>
<%
v=ob.Increase();
value = "product" + v;
t = "text" + v;
%>
<html>
<input type=text name=product value="<%=value%>">
<div id='<%=t%>'></div><br>
</html>
AddProd1.jsp:
<% int i;
String [] value = request.getParameterValues("product")
for(i=0;i<value.length;i++)
out.println(value[i]);
%>
无论我尝试什么,我都会在AddProd1.jsp中的“value.length”中获得异常....我甚至试图通过只放置request.getParameter(“product”)来获取一个值...但是我得到了作为回报的空值....我做错了什么??? Thanx in advace ..