0

About a week ago, I inherited a monitoring and notification tool which is written in Python. I am tasked with creating a proof of concept for a dashboard based on the data that the tool has collected over the years. Unfortunately, I am new to Python and have never done CGI programming - so a perfect mismatch. :) I am using tomcat7 because it is already installed in the machine.

The problem is that I am not able to get my generated HTML page to read the CSS file. My directory structure under webapps/myapp is as follows:

$ tree
  .
  ├── graphpages.css
  ├── index.html
  ├── META-INF
  │   └── context.xml
  └── WEB-INF
      ├── cgi
      │   ├── hello_world.cgi
      │   └── page1.cgi
      └── web.xml

I have tried to refer to the CSS in my HTML as follows:

<link rel="stylesheet" type="text/css" media="screen" href="../graph_pages.css" />

Tried moving the file graph_pages.css under WEB-INF/ and also by creating a directory htdocs/ under WEB-INF/ and placing the file inside that. Meaning:

$ tree
.
+-- index.html
+-- META-INF
¦   +-- context.xml
+-- WEB-INF
    +-- cgi
    ¦   +-- hello_world.cgi
    ¦   +-- page1.cgi
    +-- graphpages.css
    +-- web.xml

and

$ tree
.
+-- index.html
+-- META-INF
¦   +-- context.xml
+-- WEB-INF
    +-- cgi
    ¦   +-- hello_world.cgi
    ¦   +-- page1.cgi
    +-- htdocs
    ¦   +-- graphpages.css
    +-- web.xml

Of course, I updated the generated HTML too. But no help at all.

My browser is able to open the CSS file in the first directory structure above but not in the other two cases.

Please help me understand what the directory structure should be and how I can get the CSS to have an effect on the page.

1 Answer 1

2

When having graphpages.css at the root level with index.html use the web root / as the starting point as opposed to a relative path ../:

<link rel="stylesheet" type="text/css" media="screen" href="/graphpages.css" />

Note: You have some references to graphpages.css and graph_pages.css. Please make sure you're consistent with the file name

Sign up to request clarification or add additional context in comments.

8 Comments

That file name miss was a good catch. Thanks. The name of the file was wrong. But changing it does not seem to fix the issue and modifying href does not seem to fix it. Please help.
make sure that when accessing myapp.com/graph_pages.css the css file pulls up.
Other things to try: chmod 755 graph_pages.css, make sure you have a html content type header in the cgi script
This is the portion till body tag starts: <!DOCTYPE html> <html> <head><title>Title</title> <link rel="stylesheet" type="text/css" media="screen" href="/graph_pages.css" /> </head> <body>
The file has 777 permissions. and I am able to access myapp.com/graph_pages.css directly from the browser
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.