Submitting an AJAX JSP does not make sense, it is basically HTML code generated by the JSP that is sent to the browser via AJAX, as rightly points to thelost.
You do not need server-side coding for this. All you need to do is write client-side javascript to get your asynchronous HTML code. For this, I would recommend using some javascript framework, for example jQuery, otherwise it would make your life hell.
Assuming that the page you want to access, AJAX has a link http: // domain: port / mypage.htm . First you need to include jQuery in the JSP base (JSP in which the previous page should load AJAX):
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.js"></script>
Then you need to call the jQuery ajax function:
$(document).ready(function(){
$.ajax({
type:"GET",
url: "http://domain:port/mypage.htm",
success: function(data){
alert(data);
}
});
});
Hope this helps!
source
share