在ajax调用之后加载JSP

I have a requirement were I need to make a ajax call to invoke my servlet which will update the servlet context with data. The data from servlet context will be used in JSP. The problem I face is, the JSP is loaded before the ajax call. How can I get the servlet context updated before the JSP is loaded.

What i have understood from your question is that you want to load the data to the jsp only after all the data is loaded into the session. So for this what we can do is below:- $("#results").load("your jsp", function() { ... some code... });

Adding async:false to AJAX call solved my problem.