I'm sure this question has been asked many times in this forum but my searching has not revealed a concrete answer for me.
I have a JSP that has several enterable fields, all of which are to be used to build an XML document to be written on a directory on a server. This same JSP page has a HTML "Submit" button tag that has an "on-click" event handler code. When the user enters data into all of those fields and clicks the submit button, I would like to call a POJO, sending to it all of the data elements that were entered in those enterable fields and have that POJO create and write out the XML file.
I'm sure there must be a way to complete such a fundamental process, but I cannot find a solution.
Thank you for your time.
And yes, Ajax is the answer.
In the JSP, you should be able to call a POJO and make it create an XML with the data received, since it's on the server side.
Do a little search on Google about AJAX and you will soon find how to do it. I recommend W3Schools.
Emmanuel F. Borges wrote:function will be responsible for sending your form-data to a JSP ...
Sending data to a JSP for processing is considered a poor practice. A servlet is more appropriate.
justin chin wrote:Yes, within a JSP you can call a POJO type method.
And, scriptlets have been discredited for almost 10 years now, please do not encourage their use,.
3. You can use a JSPF to contain the java code "methodName" that can access the Web App Server Java layer to keep things a little cleaner. This of course then can access anything you can imagine including POJO's.
This probably isn't the recommended way to solve this solution, but this answers you question directly.
justin chin wrote:
Your misunderstanding of how JSP works can be addressed by reading this article.