Not able to retrieve hidden field value from the Form into the servlet
843842Feb 11 2010 — edited Feb 12 2010Hi,
Currently i am coding a web application program in servlets. I have a form having fields in servlet which adds a record . I have a ADD button in the form which when clicked causes the entered record to be displayed in a table in the same servlet. The validations for the field are done in a javascript and i am using a hidden variable "action" in the javascript to which i am assigning "ADD" if add button is clicked .If i am trying to access the same hidden field in the servlet using request.getParameter i am getting "null" value in the servlet. How to resolve the issue.Currently i am using Eclipse Galileo IDE for development purpose.Any help provided on it would be greatly appreciated .
Code in the javascript
-------------------------------
function fnValidate{
document.BookForm.action.value = "ADD"
}
Code in the servlet
--------------------------
protected void doService(HttpServletRequest request, HttpServletResponse response){
// The Form displayed using servlet
out.println("<form name=\"BookForm\" method=\"post\" action=\"SaveBookServlet\">");
// The fields in the form
.........
String action = (String) request.getParameter("action");
System.out.println("action is "+action);
/* The above string is getting printed as null in the eclipse console */
if(action != null){
if(action.equals("ADD"){
Display the record
}
else if(action.equals("BACK"){
......
}
}