call a jsp method from javascript
10,328
What you're looking for is how to create an ajax request. You can do it without jquery or easily with jQuery:
$.post('new.jsp',{ param1: 'param1value', param2: 'param2value'},function(data){
if(data){
console.log(data); // response from your server
}
});
There's a lot more info in the jQuery docs
Author by
Dineshkani
Updated on June 08, 2022Comments
-
Dineshkani almost 2 years
I use a method in jsp page like this and the page is saved in the name of new.jsp
<%! public void createXml(String graph) throws Exception { try { String str="dinesh" DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = builderFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); } catch(Exception e) { System.out.println(e); } } %>
If i call this page like this
<form method="post" action="new.jsp">
But, I want to call this method of createXml only using javascript or jquery coding because i am going add various method in the new.jsp. Any one help this to call method without calling the whole jsp page