• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Custom page 404 css not picked up due topath issue

 
Greenhorn
Posts: 16
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The answer is:

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

Thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Although it would be better to use the EL rather than obsolete scriptlets.
 
reply
    Bookmark Topic Watch Topic
  • New Topic