Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:23:11+00:00 2026-05-27T01:23:11+00:00

I am learning both AJAX and the Java Servlet API (well, Spring MVC, which

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:23:12+00:00Added an answer on May 27, 2026 at 1:23 am

    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.

    I think your confusion is rooted in thinking about AJAX requests and non-AJAX requests as being fundamentally different. First of all, it is important to know what AJAX is. From wikipedia:

    Despite the name, the use of XML is not needed (JSON is often used
    instead), and the requests do not need to be asynchronous.

    I would also add that some other browser scripting language besides JavaScript could be used instead. So the name tells you absolutely nothing. “AJAX” basically just means that an HTTP request is being kicked off from a script in the browser as opposed to a request that originates from someone typing a URL in the address bar for example.

    So the scripting code that generated the HTTP request may choose to handle any HTTP response that the server sends or it can ignore it. How the request was generated — “AJAX” or non-“AJAX”, need not have any bearing on the HTTP response that is returned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should I learn Java before learning Android or I can do both things in
I'm relatively new to Android development and Java (learning both simultaneously sort of...). My
I need a decision tree learning library for Java. I've looked at both jaDTi
I have a web app which has standard things for learning based app like
I am still learning socket programming (using Perl) but I have both options (
For learning and demonstrating, I need a macro which prints its parameter and evaluates
After learning that both strncmp is not what it seems to be and strlcpy
I am learning scheme. I know how to use both lambda and let expressions.
I am learning cakePHP 1.26. I got a Controller which got two functions. I
i am learning Java at the moment and have the following question: i am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.