aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes document.location context jumbled up in Chrome and Safari using Struts mappings ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "document.location context jumbled up in Chrome and Safari using Struts mappings ?" Watch "document.location context jumbled up in Chrome and Safari using Struts mappings ?" New topic
Author

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

Joel Alvim
Greenhorn

Joined: Mar 29, 2010
Posts: 1
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!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Don't use a relative link.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: document.location context jumbled up in Chrome and Safari using Struts mappings ?