I am learning both AJAX and the Java Servlet API (well, Spring MVC, which is based upon Servlets) at the same time, and believe I am understanding most of the basics, except when it comes to understanding how HttpServletResponse is structured/organized/populated differently when the server/Servlet is responding to an HTTP GET/POST (as it would with a normal page request) as opposed to an AJAX-based XmlHttpRequest.
It seems to me that, in the absence of AJAX, every HttpServletResponse would just contain the full HTML (plus header/metadat/etc. info) for the page. With AJAX, asynchronous XmlHttpRequests can be used to update specific components inside a particular page. Thus if I understand HTTP and Servlets correctly, a request for http://www.example.com/some-page.html might result with an HttpServletResponse containing the following body:
<html>
    <header><title>Title of the page</title></header>
    <body>
        <!-- Some massive amount of HTML -->
        <a href="./foo.html">This is a link</a>
        <!-- Lots more HTML -->
    </body>
</html>
Whereas, with an AJAX request, somehow the HttpServletRequest might send back information so that the link (from the example above) now renders to this:
<a href="./bar.html">This is a new link that point to bar</a>
My question is: How do Java Servlets structure HttpServletRequests to handle both full page requests as well as AJAX requests that may only produce changes to parts of a page?
As a segue into a similar-yet-separate question is how clients (browsers) know to take the HTTP Responses (sent back by the Servlet) and either render a whole new page or just update a small part of a page.
Thanks in advance for any clarity on the matter.
 
     
     
     
    