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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:09:46+00:00 2026-05-10T19:09:46+00:00

I have an application in which most requests are submitted via AJAX, though some

  • 0

I have an application in which most requests are submitted via AJAX, though some are submitted via ‘regular’ HTTP requests. If a request is submitted and the user’s session has timed out, the following JSON is returned:

{'authentication':'required'} 

The JavaScript function which submits all AJAX requests handles this response by showing a popup message and redirecting the user back to the login page.

However, when a non-AJAX request receives this response the JSON is simply shown in the browser because the response is processed directly by the browser (i.e. the aforementioned JavaScript function is bypassed). Obviously this is not ideal and I would like the non-AJAX requests that receive this response to behave the same as the AJAX requests. In order to achieve this, I can think of 2 options:

  1. Go through the application and convert all the requests to AJAX requests. This would work, but could also take a long time!

  2. The JSON shown above is generated by a very simple JSP. I’m wondering if it might be possible to add a JavaScript event handler to this JSP which is run just before the content is displayed in the browser – I’m assuming this would never be called for AJAX requests? This handler could call the other JavaScript code that displays the popup and performs the redirection.

If anyone knows how exactly I can implement the handler I’ve outlined in (2), or has any other potential solutions, I’d be very grateful if they’d pass them on.

Cheers, Don

  • 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. 2026-05-10T19:09:47+00:00Added an answer on May 10, 2026 at 7:09 pm

    You cannot add a handler to the JSP that way. Anything you add to it will make it a non-JSON producing page.

    There are two options that I can see: Add a parameter to the page by appending a URL parameter to the screen that modifies the output.

    URL: http://domain/page.jsp?ajaxRequest=true would output json only

    URL: http://domain/page.jsp would display a jsp page that could forward to another page.

    OR

    change the response to have the forwarding code in the JSP that will get executed by the web browser if it is hit directly. Then have your calling AJAX to strip the forwarding code out, and then process what is left.

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

Sidebar

Related Questions

I have an application which really should be installed, but does work fine when
I have an application which extracts data from an XML file using XPath. If
We have an application which needs to use Direct3D. Specifically, it needs at least
I have an application which behaves as a slideshow for all pictures in a
I have an application which is a portal application and I want to allow
I have an application which takes a string value of the form %programfiles%\directory\tool.exe from
I have an application which get copied and run on client machines. The program
I have an application which has to live as a service, I create an
I have one application which uses the standard .NET forms authentication cookie, now I
I am currently writing a user management application which administers users in a single

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.