Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes filter, forward,ajax call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "filter, forward,ajax call" Watch "filter, forward,ajax call" New topic

filter, forward,ajax call

Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
I have a request to my site, intercept it, and since I know there is nothing, I forward request to valid address

Then it arrives to the exact page that I want. On that page java script:

Now the prob is that ajax no longer calls to
but instead to
which does not exist there.

Any advice ?

I guess I have to change request, before I forward the whole thing ?

Searchable nature photo gallery:
Rob Spoor

Joined: Oct 27, 2005
Posts: 19653

Moving to Servlets.

How To Ask Questions How To Answer Questions
Markas Korotkovas

Joined: Jan 27, 2011
Posts: 21

In your second snippet you have "catchAjaxRequest.jsp" which is relative path, so when making the request the whole context is included (everything after the domain in your URL). In order to exclude the context add a / like this "/catchAjaxRequest.jsp". This will result in a URL like which is what you are looking for i think.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60782

The URL should start with the context path of the web application, which is not necessarily just /.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Miran Cvenkel
Ranch Hand

Joined: Nov 23, 2010
Posts: 147
Thank you both. That was helpful.
I agree. Here's the link:
subject: filter, forward,ajax call
Similar Threads
escaping url, sitemap, filter
Designing a shopping cart
Value shows up in url
How To "Forward Request" in JSP
Servlet chaining