-1

I use this js function to submit my form.

function updateAction(obj,tableName){
  inputs=obj.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("input");
  newValues="";
  for(i=0;i<inputs.length;i++){
    newValues+=inputs[i].value+",";
  }
  obj.parentNode.parentNode.parentNode.parentNode.parentNode.action="SimpleServlet?action=update&tableName="+tableName+"&newValue="+newValues;
  obj.parentNode.parentNode.parentNode.parentNode.parentNode.submit();
}

and the action of form has correctly been changed to

"http://localhost:8081/SimpleWeb/SimpleServlet?action=delete&tableName=stude…01199203110000,200301,%E5%85%83%E5%AE%9D,%E7%94%B7,3,yb,424551199104010000,"

and in my servlet

String action=(String)request.getAttribute("action");
String tableName=(String)request.getAttribute("tableName");
System.out.print(request.getAttribute("tableName"));
System.out.print(request.getAttribute("action"));
System.out.print(request.getAttribute("newValue"));
String[] newValues=((String)request.getAttribute("newValue")).split(",");

but they are still null,why?

Stillily
  • 39
  • 1
  • 9

2 Answers2

0

If you are sending your parameters by URL try using request.getParameter(name);

Jean Cedron
  • 702
  • 3
  • 14
0

You are sending parameters, try request.getParameter:

String action = request.getParameter("action");

request.getAttribute is used to get the attribute set on the server side using request.setAttribute.