aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes Is it to hide my javascript in the project directory? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Is it to hide my javascript in the project directory?" Watch "Is it to hide my javascript in the project directory?" New topic
Author

Is it to hide my javascript in the project directory?

tangara goh
Ranch Hand

Joined: Dec 27, 2009
Posts: 125
Dear experts,

I'm wondering is it possible to hide my javascripts that do the validation of forms under the directory of my project folder, just like the way CSS can be hidden away in the directory? However, I'm not sure how it can be done. Hope someone can share with me how. Many thanks.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure what you're asking.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56214
    
  13

Seems to be a web app question, so I've moved it to the Servlets forum.

What do you mean by "hide". You can't "hide" CSS, or it wouldn't work. So you'll need to explain what you mean by that.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
tangara goh
Ranch Hand

Joined: Dec 27, 2009
Posts: 125
David Newton wrote:I'm not sure what you're asking.


What I meant is that I would like to tuck away the Javascripts at the directory, just like css.

With css, I can just put a reference link to the stylesheet and I hope to do the same for my javscript .

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56214
    
  13

OK, well "hiding" is certainly not the right word for that.

So you are asking if you can move the JavaScript out of the page and into a separate file? If so, then yes. Create a file containing the script, give it a file type of .js, and use the src attribute on the script tag to reference it.

Example:

[Moved to the HTML forum.]
tangara goh
Ranch Hand

Joined: Dec 27, 2009
Posts: 125
Bear Bibeault wrote:

So you are asking if you can move the JavaScript out of the page and into a separate file? If so, then yes. Create a file containing the script, give it a file type of .js, and use the src attribute on the script tag to reference it.

Example:

[Moved to the HTML forum.]


OK. But, the thing is I can't find a folder for this js in Netbean IDE. After right-clicking my project name, should I file it under others+ ?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56214
    
  13

It doesn't matter where you put it as long as it within the web app, but not under WEB-INF. Forming the URL to the file should be done using full server-relative addressing which is discussed in the JSP FAQ.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it to hide my javascript in the project directory?
 
Similar Threads
Tomcat JSP URL Mapping
How to hide some ressources ?
soft imported project (Eclipse)
problem in paging using javascript
How to hide EditorPart(RCP)