Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call Java Script Function in JSP from JAVA Class

 
Vinoy Paul
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

Is there any way i can call the a javascript function from my java class.
i am using JDK 1.5 . In 1.6 i think there is a way like script engine. But i could not find out same in 1.5.

Please help
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript runs on client/browser and JSP runs on server.

BTW, what is script engine?
 
Vinoy Paul
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I know that javascript runs on client end.

But still you can create a javascript function through java class and call it . Which can easily done in Java 1.6 through ScriptEngineManager.

Please visit the url http://www.coderanch.com/t/549722/java/java/Calling-Javascript-function-Java-Code

 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Why do we use such a thing? Sometime back somebody said we use javascript for writing servers, and i was wondering how javascript is executed in such a case for i thought the only way javascript can be put to use is to be interpreted by a browser.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot execute JavaScript in the browser from the server-side Java.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Why do we use such a thing?


Some folks just like to use scripting languages, I guess it is an acquired taste.

As I understand it, the scripting engine that used to be the Apache Rhino project got built into Java 1.6.

Bill
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic