Link to home
Start Free TrialLog in
Avatar of softechnics
softechnics

asked on

External CSS and JS files not included in HTML under Linux

My Javascript and CSS files are not being referenced by my HTML file when running under Linux. Under Windows, all is fine and everything works. I've checked case on all files. I'm running Tomcat 6.0 on Windows and Tomcat 5.5.20 on Linux.

HTML code snippet:

 <jsp:include page="js/globals.js" />
<jsp:include page="js/transferScan.js" />
<link rel="stylesheet" href="css/softRetail.css" type="text/css" media="screen" >

Any thoughts?
Avatar of peter-blackwood
peter-blackwood
Flag of United States of America image

Since you don't have a leading slash in front of "js/globals.js", Tomcat is trying to find the referenced files using a path name relative to the current JSP page.  (i.e. the one containing the includes)  That's probably why they can't be found.  If you use a leading slash, i.e. "/js/globals.js", Tomcat will resolve it using the Web context, i.e. as if it were an HTML page.  
Avatar of softechnics
softechnics

ASKER

The directory 'js' is under the current directory.
Tried putting '/' at start of pathname, but, as expected, no change.

Thanks for the suggestion. I welcome any others.
Your original post said the "HTML" code snippet - I'm assuming you meant it's a JSP file, correct?  

Are you creating a war and FTP-ing it to the Linux server or are you copying loose files?

Yes, they are JSP files. And, yes, I had just copied the 'loose' files to the directories. I am now editing those files in place.

problem?
To clarify our installation of Tomcat, our SysAdmin installed Tomcat under an existing Apache web server installation. He did this so the tomcat webapps could be referenced via port 80 (I THINK that was the reason he gave me some months ago.) Hence,a tomcat directory exists under the Apache htdocs directory.

Therefore, the URL to my webapp is: http://<Company URL>/tomcat/webapps/<My WebContext>/transferScan.jsp

Hope this keeps things on track.
I have opened up the JSP servlet in web.xml under tomcat/config. Do I need to do anything else to activate JSP page processing? I ask, because when I try to open the tomcat index.jsp page in tomcat/webapps/ROOT/, I get an error "The XML page cannot be displayed" and it points to the line:
<%@ page session="false" %>
Like it doesn't understand the JSP tags.
ASKER CERTIFIED SOLUTION
Avatar of peter-blackwood
peter-blackwood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good suggestion. So good, in fact, that I've been moving that way this afternioon. Downloaded v6.0.18 and deployed it. Now setting up appropriate links. My Unix/Linux is rusty, so progress is slow.

Thanks for the replies. They got me thinking.
You got me thinking in the right direction. Points are yours.