• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling .js in jsp

 
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I'm trying to call .js file in my jsp but it;s not working here is the code :

Anything i'm missing ?
 
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is your js Folder ?. In unix machine or windows machine. If in unix add '/' prefix <script type="text/javascript" src="/js/Calendar.js">

For Import use the head section not body

 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Meet Gaurav wrote:Where is your js Folder ?. In unix machine or windows machine. If in unix add '/' prefix <script type="text/javascript" src="/js/Calendar.js">

For Import use the head section not body


It's on Windows machine , here is the full path for my js
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D:\folder1\eclipse\workspace\Audit\WebContent\js\Calendar.js

So your HTML is D:\folder1\eclipse\workspace\Audit\WebContent\HTML.html. Then use

<head>
<script type="text/javascript" src="js/Calendar.js">
</head>
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this but it;s not working too !!!
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are getting any script errors ? if so send that

Try to put some alert(); statement inside ds_sh()
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<script type="text/javascript" src="<%= request.getContextPath() %>/js/calender.js"></script>
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brijesh Verma wrote: <script type="text/javascript" src="<%= request.getContextPath() %>/js/calender.js"></script>



This is not working too !!?
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even i tried to put the javascript code between the <script> blocks it's not working too ...

Anything i'm missing ?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
with script tags you have to have a closing script tag



If you do not include it, it will not work.

Eric
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:with script tags you have to have a closing script tag



If you do not include it, it will not work.

Eric



Hi Eric,

Do yo mean <@include file = "" /> ?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. "include it" was referring to the closing script tag.

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sherif Shehab wrote:

Eric Pascarello wrote:with script tags you have to have a closing script tag



If you do not include it, it will not work.

Eric



Hi Eric,

Do yo mean <@include file = "" /> ?


No. He meant to include the closing tag.

Have you read the JSP FAQ entry on this issue? You should be using server-relative URLs in a JSP.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok i'll read it , by the way i wrote this tag <script type="text/javascript" src="js/Calendar.js"> in another jsp and it works fine !!! so what do you think i'm missing ?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are missing the fact that "current directory" is usually not meaningful in JSPs and you need to use server-relative addressing rather than page-relative addressing. It's all explained in the FAQ.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some browsers will allow you to drop the closing tag, but most browsers do not allow it. Use it.

Eric
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic