Solved

External CSS and JS files not included in HTML under Linux

Posted on 2008-10-31
10
722 Views
Last Modified: 2013-12-02
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?
0
Comment
Question by:softechnics
  • 7
  • 3
10 Comments
 
LVL 1

Expert Comment

by:peter-blackwood
Comment Utility
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.  
0
 

Author Comment

by:softechnics
Comment Utility
The directory 'js' is under the current directory.
0
 

Author Comment

by:softechnics
Comment Utility
Tried putting '/' at start of pathname, but, as expected, no change.

Thanks for the suggestion. I welcome any others.
0
 
LVL 1

Expert Comment

by:peter-blackwood
Comment Utility
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?

0
 

Author Comment

by:softechnics
Comment Utility
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?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:softechnics
Comment Utility
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.
0
 

Author Comment

by:softechnics
Comment Utility
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.
0
 
LVL 1

Accepted Solution

by:
peter-blackwood earned 500 total points
Comment Utility
Sounds like you might benefit from a full reinstall of tomcat.   Try to get the manager app working first (http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html) then imitate that configuration for your own code.

My style of working is to get my app working on my workstation first (sadly, that would be Windows) using http://localhost:8080/blah/blah and when it works as expected, build a war file and deploy the war file to the server.  Often just building a war using ant, maven, or eclipse will catch errors in your project structure that can cause issues when deployed.

Sorry I can't be more helpful.
0
 

Author Comment

by:softechnics
Comment Utility
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.
0
 

Author Closing Comment

by:softechnics
Comment Utility
You got me thinking in the right direction. Points are yours.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now