• 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

document.location context jumbled up in Chrome and Safari using Struts mappings ?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

First of all I'm new to the forum, so hopefully I'll find here a nice and cozy place to discuss Java matters ;)

Now to my problem, suppose you have a struts mapping defined as contract.do, which points to a jsp located in the war file at /contracts/contract.jsp
The application runs at a defined context of /contractsapp for example. So you would access http://server/contractsapp/contract.do

On that page you would have a div with onclick="document.location='listDetails.do'"

When you click the div in IE or Firefox, you get forwarded to http://server/contractsapp/listDetails.do as I would expect. Since the document.location declares no context, I would assume the browser to just reuse the same context as the current page and replace the last bit (the struts mapping) with the new one.

However in Chrome or Safari you get redirected to http://server/contractsapp/contracts/listDetails.do

This last mapping doesn't work! It seems like Chrome and Safari react differently to document.location when no context is specified. Chrome and Safari will take what's on document.location, and append that to the actual folder where the jsp is located, not just the struts mapping.

The solution to this in my case would be to replace everything in document.location with a little jsp bean that contains the context (using jsp's application object) and then manually appending the struts mapping I want. But this means changing my app in lots of places and re-testing. Is there an easier way to go about this ? Some meta-tag that I'm missing that will change Safari and Chrome's behaviour ?

Thanks for any replies, I hope I explained the problem properly!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't use a relative link.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic