Getting Null value from request.getParameter() [duplicate]

筅森魡賤 提交于 2020-02-06 06:42:09

问题


In my application,with the help of joining,I am showing the dynamic value in my jsp page like this :

<%  while(rs.next()){ %>
<td><input type="checkbox" name="chkName" onclick="selectall()"></td> 
<td><input type="text"  name="empId" value="<%= rs.getString(1)%> "   disabled="disabled"  maxlength="10"></td>
<td><input type="text" name="device" value="<%= rs.getString(2)%>"   disabled="disabled" maxlength="10"></td>
<td><input type="text"  name="features" value="<%= rs.getString(3)%>"  disabled="disabled" maxlength="60"></td>
<td><input type="password" name="password" disabled="disabled"></td>
<td><input type="text"  name="policyName" value="<%= rs.getString(4)%>"  disabled="disabled" maxlength="10"></td>
</tr>
<% } 
%>

And whenever from another servlet(as I want to show the fetching from this jsp to another jsp ) I am calling request.getParameter("empId"),it is fetching the "NULL" value.I think,I have to use set(session.setAttribute() or request.setParameter()).

Any suggestion will be appreciated.


回答1:


Might be because of the disabled attribute .. maybe you can replace it with readonly instead?




回答2:


Do you mean to say you need to pass values between 2 jsp pages? Then you could use it by setting it in a hidden input field or set it in session...

check if this helps you... Using request.setAttribute in a JSP page




回答3:


Another simple way.

You can add a hidden type .

<td><input type="text" value="<%= rs.getString(1)%> "   disabled="disabled"  maxlength="10"></td>
<td><input type="hidden"  name="empId" value="<%= rs.getString(1)%> "  maxlength="10"></td>



回答4:


try request.getParameter("empID") for the field named empId not <i>empId. Hope that helped , just rename the field in the form



来源:https://stackoverflow.com/questions/10613117/getting-null-value-from-request-getparameter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!