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 7583887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:47:27+00:00 2026-05-30T18:47:27+00:00

Im using an ajax script to send a request to a servlet which in

  • 0

Im using an ajax script to send a request to a servlet which in turn sends a request to a database and then when the database returns some data to the servlet, the servlet returns the result back to the web page. The problem is, this same script is used again on another page to do exactly the same thing except the output needs to be different.

My idea was to determine what page the request came from and format the response using this information.

Ive tried HttpServletRequest req.(almost everything the API allows) to try and get the required information but it doesn’t appear to return what i need. I can get it to return the servlet address using request.getRequestURL but I need the webpage this request originated from, not where it was sent.

Am I missing something obvious here ?

  • 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-30T18:47:29+00:00Added an answer on May 30, 2026 at 6:47 pm

    There is an HTTP Header called “Referer” that contains the information from which page the request was triggered. For AJAX requests, this header normally contains the URL of the page in which the AJAX request was triggered. You can get this header using request.getHeader(“Referer”), so you could try if that is what you need.

    But it’s up to the client to send that header, so you cannot be sure that it will always be there. And this approach may also lead to maintainability issues, e.g. if you move you web page to a different URL. So it may be the better design to parameterize your JavaScript and you servlet, i.e. the client adds a parameter to the URL that tells the servlet from which context the request is coming from or what the expected output format is.

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

Sidebar

Related Questions

I want to send a POST request to a PHP script which then will
I'm trying to send an ajax request using jquery. From the tutorial, I try
Situation: I send an ajax request that returns HTML containing elements needing event handlers
I am using dojo and ajax to send a time stamp to PHP, which
i am using ajax and jquery to send an * synchonou *s http request
Having some problems with getting some ajax script to work. Using this as the
I have to request data for a JS-script from a MySQL database (based upon
i am using Ajax to send JSON data over to my server for a
We are using the Dynamic Script Tag with JsonP mechanism to achieve cross-domain Ajax
When I'm using AJAX, I typically do something before each request to let the

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.