Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding external javascript in JSF

I want to insert an external javascript file in my JSF page. So what I did is:

Now, the JSF file is named start.xhtml and both are sitting in the same folder. However, when I ran , there is nothing happend [ The javascript supposed to pop up alert when I click]. I checked the page source, and apparent in the .

What did I do wrong to get the RES NOT FOUND? I even put absolute path but nothing happened :(. Me sad panda.

Fyi, I am using the latest Netbeans.

Thanks, Song.

like image 278
Haikal Nashuha Avatar asked Jan 21 '23 14:01

Haikal Nashuha


1 Answers

Try including your script this way

<script src="#{facesContext.externalContext.requestContextPath}/yourPathAfterWebpages/scriptFile.js" type="text/javascript"></script>
like image 80
niksvp Avatar answered Jan 29 '23 10:01

niksvp