AJAX Post - Performed in JSP, need to return java based variables in the AJAX POST Success function
===

I am using ajax post within a JSP, to send json data to a servlet java class. Within the servlet controller class I used getparameter to get the data being sent from the calling JSP.

This all works fine, to this point. I then initate processing of the data in from this servlet class, and I need to formulate a data response to send back to the calling JSP. 

Is there a way that I can hold the data in variables within the servelt class, and as part of the success function (within my AJAX post) access this data?

My AJAX Post code:

		$.ajax({ 
			type:        "POST", 
			url:           url, 
			dataType:  "text",  // [text, xml, json, script, text, html]
			data:       {postData : myData, sendURL : postUrl},	
			success:    function(data, textStatus, jqXHR) { 
				alert('Success post to URL entered \n\n The data returned the following: ' + data);
			}, 
			error:function (xhr, ajaxOptions, thrownError){ 
			    alert('Error xhr : ' + xhr.status); 
			    alert('Error thrown error: ' + thrownError); 
			}
			//complete: alert('complete')                   
		}); 

My Servlet Controller code:

		@RequestMapping("/postData")
		public String postData(Model model, HttpServletRequest request) throws Throwable{

			String postData = request.getParameter("postData");
			String sendURL= request.getParameter("sendURL");

			System.out.println(this.getClass() + " : postData   : " + postData);
			System.out.println(this.getClass() + " : gatewayURL : " + gatewayURL);

			/* Process data and formulate a response.... */
			
			String responseText = processedResponseText; // This processedResponseText was populated in the internal processing
			String responseCode = processedResponseCode; // This processedResponseCode was populated in the internal processing

			return "callingJSP";
		}

As part of my AJAX Post - Success function, how can I get these two variables (responseText and responseCode) back to the calling JSP?

Many thanks