Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

calling js file..

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
im using tomcat 4.0
i have js file which i want to include in a jsp file..how shld i give the path for the js file ??
i have kept the jsp files in the direcory named jsp and js files in a directory named js
the directory structure is
test // context path
|
| - Jsp
|
| - js
it works properly on html files..
i have tried everything like
<script language="JavaScript" src="../js/test.js">
<script language="JavaScript" src="/test/js/test.js" >
can any1 help me ?? im not sure where to post to doubt..is it anything related to tomcat setting ??
thanks
raj
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
src="js/test.js" should work

Remember that the browser is calling this for you, and it's not being included server-side (which is another option actually).

So your javascript and images should all be referenced from the application root.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes u are right, but its NOT WORKING.. what shld i do ??? its very urgent ?? I tried the same thing on Windows 98..its working there but in WIN NT its not working..
raj
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mike,
Atlast I solved it..The culprit was the name of the 'js' directory..The name of my js directory was "Js" not "js" so i shld have given the src of js file as

<script .... src = "../JS/test.js">
</script>
i donno why ???
I have one more situation..im using two js files in the same "Js" directory..by giving the above <script src ..> I was able to access the one js file but the second one is not getting inlcuded..huh !! im tired ...
thanks for ur reply
raj
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first, i always assume that things are case-sensitive. Java is. Unix is. Windows isn't, but Java *on* Windows still is. So to avoid confusion, I always make sure my case is correct.

As for the second problem, it seems quite odd. Again, just make sure the spelling and case are correct. With windows, make sure the file is not named something like 'file.js.txt' and the .txt is being hidden by the OS. Also, since the browser is making the request, ensure your cache is emptied, and set IE to check "every visit to the page" when you're developing web pages.
 
Shiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic