/    Sign up×
Community /Pin to ProfileBookmark

Java code inside javascript file

Can you place java code in an external javascript file (.js). For example can I do the following in my xx.js file.

$(document).ready(function(){
<% execute some java code here %>

…execute some javascript code here…
})

Can I do the above?

Another question …
I know <% %> is to execute java code inside html. But what does <%– – -%> mean?

Thanks for any help.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Nov 09.2011 — Yes, but remember that the Java code will run first, and then when it's sent to the browser, the JavaScript will run. Also, you may have to configure your server to parse JavaScript files for Java.
Copy linkTweet thisAlerts:
@sportyNerdauthorNov 09.2011 — Thanks!

Can you tell me what does <&#37;-- s ome code here --%> mean? Is it a comment?
Copy linkTweet thisAlerts:
@sportyNerdauthorNov 10.2011 — Hi:

How do you configure Tomcat to parse Java in Javascript .js file?
×

Success!

Help @sportyNerd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...