• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Appending query strings to a URL

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone help?
I'm trying to append a querystring to an existing url (eg http://abc.com/servlet/testservlet) and to send that same url back to the client but with the querystring added.
If I use response.sendredirect(existingUrl + querystring) to achieve this, the browser just tries to execute the new url and returns to my code, resulting in an endless loop - is there any way around this?
[ January 14, 2003: Message edited by: mike canmore ]
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike,
If you are using this:

then you need to check to see if the new stuff is there before you send the redirect, like this:

I hope this makes sense.
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the ? included in your querystring? If not, try this:

hth,
-Pat
 
Pat Wallwork
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I reread your question and understand what your trying to do now. Tom's suggestion sounds good. If your not checking for a query string then your servlet will keep redirecting the client resulting in that endless loop.
Another idea might be to use the session.

-Pat
 
mike canmore
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your answers people.
The problem is that the code I'm writing is to be used as an application flow control mechanism "wrapped" around an an existing servlet app. To achieve this, an encrypted token is passed around the application in a querystring and is checked for validity by the filter.
If the token is invalid, then the filter directs the client to an error page, but if it's valid, the original servlet is executed, performs it's processing and uses a forward to return to the client. I was planning to use the filter to intercept the response, update the token, and then do a redirect to the original url + new token value. The problem is that even with the suggested code above, the app will still loop after the redirect as the querystring will always be the same, but just with a different value.
 
mike canmore
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW I realise that this is not a great solution, but we cannot use the session at all.
I think that cookies are probably the answer, although I was trying to avoid using them if at all possible.
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic