Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Embedd .js files in Perl n execute in Tomcat

Posted by v.akshatha.hegde (v.akshatha.hegde), 23 May 2007

I managed to execute a perl program using Apache Tomcat. But if I include some img file or JavaScript file in my perl program the server is not able to locate my img or .js file. Could any one you tell me where to place my img or .js file for the server to interpret while executing a perl program in Tomcat.

Since I am new to this forum I do not know if this is the relevant component.Please tell me if this is a wrong component as this is really urgent for me.

Any help would be appreciated.

My code is here:

print "Content-Type: text/html\n\n";

print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Experiments with JavaScript : First Page</TITLE>\n";

print "<script language='javascript' src='greet.js'>\n";
print "</script>\n";

print "</HEAD>\n";

print "<BODY>\n";
print "<H1>My First JavaScript Programs</H1>\n";
print "<P>\n";
print "This page will eventually contain a few of my JavaScript experiments.\n";

print "</p>\n";
print "</BODY>\n";
print "</HTML>\n";


alert("Welcome to my page!!!!!!!!1.");

and I have placed my js file in the same place as that of perl file. Plzzzzzzzz help!


Posted by admin (Graham Ellis), 23 May 2007
As you are generating your HTML through the cgi directory - a directory of scripts - you will need to specify a different directory in the HTML you sent out , in "server absolute", and place the extra files there.

For example,
print "<script language='javascript' src='greet.js'>\n";
print "<script language='javascript' src='/greet.js'>\n";

and the greet.js file goes in the root directory of the web site

Posted by v.akshatha.hegde (v.akshatha.hegde), 24 May 2007
Hi Graham,

Thanks a lot for the Quick help. It works  .


This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho