Elad Benda Elad Benda - 1 year ago 67
CSS Question

how to relate to a relative css of master page?

I have few html pages which are generated by my java application:

----> landin_page.html

----> index1.html

----> index2.html

----> master_page.css

I want to reference the master_page.css in the header of each html page.

how can i relate to it?

I thought to do it using absolute path, but I get 404

<link rel="stylesheet" href="/html_pages/css/master_page.css">

Pat Pat
Answer Source

Using ${pageContext.request.contextPath} is the standard way to mention the full path.

<link rel="stylesheet" href="${pageContext.request.contextPath}/css/delta_samples.css">

Adding ${pageContext.request.contextPath} does the trick.

Adding "../" also works but is not recommended as best practices !! And code might break at times if this is used.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download