how jsp server and send json data
===

I am a beginner for web application. Now I want to let client send data using json to server and receive data from server using json or xml. By searching online, I am now clear with how to program on server side. Now I use ajax to send json data. However, maybe it's to easy to code on the server, I can't find any code related to server. My server side should use JSP to read the json data, using a bean(finished) to generate some data and send the data back. Here is the code and I don't where is the problem. Can anyone give any advice to me? your help means a lot for me!

this is the ajax code on the client side. I sent two input number from a form 

    $(function() {
		$("#myform").submit(function() {
			var lat = $("#num1").val();
			var lon = $("#num2").val();
			alert("form");

			if (num1 == '' || num2 == '') {
				$('.success').fadeOut(200).hide();
				$('.error').fadeOut(200).show();
			} else {
				$.ajax({
					type : "POST",
					url : "marker.jsp",
					contenttype : 'application/json; charset=utf-8',
					data : {
						"num1" : "wtf",
						"num2" : $("#num2").val(),
					},
			
					success : function(msg) {
						$('.success').fadeIn(200).show();
						$('.error').fadeOut(200).hide();
						alert(msg);

					}
				});
			}

			return false;
		});
	});
but after I switch to the jsp page, I only found two null values displayed, here's the code on the server, I planned to send xml at the beginning and I am not sure whether the request.getParameter can work and how to send back these xml data or using json format to send the data back. Help!


    <?xml version="1.0" encoding="UTF-8"?>
    <%@ page contentType="text/xml" %>
    <%@ page	         import="javax.naming.InitialContext,net.roseindia.ejb3.stateless.*,javax.ejb.EJB,java.util.*"%>
<jsp:useBean id="cal"
	class="net.roseindia.ejb3.stateless.CalculatorBean" scope="session" />

<QueryResults>
    
    <%
			try {

				String s1 = request.getParameter("num1");
				String s2 = request.getParameter("num2");
		%>
                <%=s1%>
                <%=s1%>
		
		<%
				if (s1 != null && s2 != null) {
					List<String> textdatas = cal.GetTextResults(s1, s2);
	          
					for (String textdata : textdatas) {
						
					String textLocation= "("+textdata.split("\\t",2)[0]+")";
					System.out.println(textLocation);
		%>
		<text>
			<location><%=textLocation%></location>
			<event> <%=textdata.split("\\t",2)[1]%></event>
		</text>
		<%
					}
					
					List<String> images = cal.getImage();
					
					for(String image: images){
					System.out.println(image);
		%>			
		<image>
			<imglocation><%=image.split("\\t",2)[0]%></imglocation>>
			<path><%=image.split("\\t",2)[0]%></path>
		</image>
		
		
		
		<% 			
				}
				}
			}// end of try
			catch (Exception e) {
				e.printStackTrace();
				//result = "Not valid";
			}
		%>
	
</QueryResults>

