*
The moose likes Struts and the fly likes html:base and differneces between Chrome/Safari and IE/FireFox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:base and differneces between Chrome/Safari and IE/FireFox" Watch "html:base and differneces between Chrome/Safari and IE/FireFox" New topic
Author

html:base and differneces between Chrome/Safari and IE/FireFox

Brenda Kerr
Greenhorn

Joined: Jan 06, 2010
Posts: 3
I have inherited an application that works in IE and FireFox, but doesn't work in Chrome or Safari. Or I should say it works, but any href links don't work. I have narrowed it down to the <html:base /> that I found on the page with all the links. If I remove this tag everything works. In all browsers the tag creates this base: <base href="https://ez.ewashtenaw.org/ess/common/layout/essLayout.jsp">. In all browsers the source for the links looks the same: <a href="ToShowTimesheet.do"> but in IE and FireFox the links are resolved as https://ez.ewashtenaw.org/ess/ToShowTimesheet.do while Chrome and Safari resolve them to https://ez.ewashtenaw.org/ess/common/layout/ToShowTimesheet.do. My first question is "Why the difference?" and my second is "Why is the base tag there?" I don't put the tag in any of my apps (which all work under Chrome and Safari). My Google searching is not coming up with any answers I find enlightening.

Any answers?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

<html:base> is not a JSP tag. I'll assume it is a Struts tag. Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

The base tag is used to specify what the prefix for all page-relative links should be. If you want that to be "https://ez.ewashtenaw.org/ess/" then that is what the base tag should specify. Otherwise, the page URL is used to determine the prefix.

Personally, I avoid page-relative URLs like the plague (at least for links) and make all my link URLs server-relative which leaves no room at all for ambiguity.
Brenda Kerr
Greenhorn

Joined: Jan 06, 2010
Posts: 3
So the <http:base /> is resolving incorrectly? The way the page is formed is "common/layout/essLayout.jsp" is the base tiles definition. I also don't use tiles in my apps so I'm trying to figure out the tiles stuff too. Can I just take out the base tag? It doesn't seem to hurt anything when I do. What is the tag supposed to do for me?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

I explained what the tag does above.

More info here.

If you're not going to be using the base tag's capabilities, there's no need for it to be on the page.

As I said, I never use page-relative URLs for links. They're just too fragile. I do find the base tag handy for resolving image and style sheet references in places where it is not possible to dynamically construct a server-relative URL though.
Brenda Kerr
Greenhorn

Joined: Jan 06, 2010
Posts: 3
Thank you. I am going to take it out. It seems to be an easy fix and I need that right now.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Just be aware that if there were any URLs that rely upon the base, they may no longer be correct. Make sure you have good regression testing!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: html:base and differneces between Chrome/Safari and IE/FireFox
 
Similar Threads
Getting base tag url with pageContext.request.contextPath
File upload component - Cancel event
Copy content to clipboard
why google chrome sucks
JNLP w/ JOGL