-2

JSP form going as empty randomly after submitting with post request. I am using springboott with embedded tomcat in a openshift container. I have seen similar request in 2016 but no reply. Any help is highly appreciated.

JSP:

<textarea id="dataArea" cols="111" rows="28" name="data" Class="prj" onkeydown="limitCounter(this, countdown);" onkeyup="limitText(this, countdown);" onchange="limitText(this, countdown);" onclick="trueCount(this, countdown);">${frm.data}</textarea> 
<a href="#" accesskey="S" onfocus="javascript:saveData()" tabindex="-1"></a> 
<img src="/prj/web/images/data_button.gif" border="0" style="cursor:hand" title="ALT + S" onclick="javascript:saveData()">

Javascripts:

function saveComments()
    { document.forms[0].action='<%=contextPath%>/saveData'; 
    document.forms[0].submit(); self.close(); 
    } 

Controller:

@RequestMapping(value = "/saveData", method ={RequestMethod.POST}) 
public ModelAndView saveData(ModelMap modelMap, @ModelAttribute("frm") dataForm frm, BindingResult bindingResult, HttpServletRequest request, HttpServletResponse response) 
throws Exception { }

We had both these RequestMethod.GET and RequestMethod.POST and removed the GET from the controller, but it did not work.

This code is working fine for 50 to 60 occurrences and the next one fails and the form is empty. We have enabled the logger and it showed the empty form. The immediate next action is working fine. Note: This action is performed from the popup screen. Please let me know if you need any more details

Carlo 1585
  • 1,455
  • 1
  • 22
  • 40

1 Answers1

0

Finally the issue is resolved.
The issue is with the self.close() right after the submit action.
The root cause is the browser and it is triggering the self.close() before the submit action. We have removed the self.close() from there and close it after we received the response from controller. This fixed the issue. Thanks for the below post which helped us to identify the root cause.

Submit a form in a popup, and then close the popup