• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom page 404 css not picked up due topath issue  RSS feed

 
Ramin Esfandiari
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a custom page 404 jsp page that works fine but does not pick up the css (and image).

My directory structure:
-webapp
- -error
- - -jsp
- - - -page404.jsp
- - -styles
- - - -style.css

I have tried the following but still got no result(don's want to do embedded css because it is not only the css that I need to reference in my JSP)

<link rel="stylesheet" type="text/css" href="../styles/style.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="/style.css">
<link rel="stylesheet" type="text/css" href="./style.css">
and a few more...

Any advice?

Thanks
 
Ramin Esfandiari
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

The answer is:

<link rel="stylesheet" type="text/css" href="../error/styles/style.css">

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramin Esfandiari wrote:The answer is:

Not the best answer. Page-relative URLs in Java web apps are fragile and shgould be avoid. Use server-relative paths that start with the context path. See the JspFaq for more info.
 
Ramin Esfandiari
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the great answer. You have definitely saved me a lot of hassle in the future. The following does the trick:

href="<%= request.getContextPath() %>/error/styles/style.css"

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although it would be better to use the EL rather than obsolete scriptlets.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!