document.location context jumbled up in Chrome and Safari using Struts mappings ?
posted 5 years ago
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.
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!