File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes IE + relative URLs + js file = HTTP404 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "IE + relative URLs + js file = HTTP404" Watch "IE + relative URLs + js file = HTTP404" New topic
Author

IE + relative URLs + js file = HTTP404

Mark Wa
Ranch Hand

Joined: May 29, 2009
Posts: 122
I have a really strange problem that appears only when testing in IE.

I have set up an error handler for HTTP404s which prints data to the system.out
I have a relative url in a jsp (which is served through a struts 1 action)

The url is
the jsp containing this is within webcontent/pages/myPage.jsp
the js file is within webcontent/pages/scripts/helpPopups/myscript.js

In FF all is good. In IE I get the HTTP404 report below, but yet the scripts do work.

PAGE NOT FOUND: ***************************************

Time : 2010-08-18 13:20:05:870
Referrer : http://localhost:8080/MyApp/someAction.do <- serves up the jsp
URL that doesnt exist: /MyApp/scripts/helpPopups/myscript.js <- note that the pages folder is missing

*********************************************************

anyone know why?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Don't use relative paths.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

See the JSP FAQ for information on forming proper server-relative URLs that start with the context path.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark Wa
Ranch Hand

Joined: May 29, 2009
Posts: 122
Thanks guys, but the problem is not with the context path, but the next directory after the context path. Also the app tends to be run on different servers and protocols (HTTP/S) so using absolute paths would be a major pain.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

No one said anything about absolute paths. You can start using proper URLs, that start with the context path, or you can continue to have issues. The choice is yours.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IE + relative URLs + js file = HTTP404