Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IE + relative URLs + js file = HTTP404

 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use relative paths.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the JSP FAQ for information on forming proper server-relative URLs that start with the context path.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic