aspose file tools
The moose likes JSP and the fly likes Can I call a javascript method from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Can I call a javascript method from JSP" Watch "Can I call a javascript method from JSP" New topic
Author

Can I call a javascript method from JSP

Ram Kas
Ranch Hand

Joined: Jul 26, 2006
Posts: 81
Hi,

Can I call a javascript method from JSP?

for example,
<%

Connect.getModules(Connect.getConnection(),"<%=moduleList(this.form)%>");


%>

is the above code valid considering moduleList is a javascript function.

Thanks in advance.

Dinakar.K
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56549
    
  14

No. Please read this article to understand why.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Yuval Goldstein
Greenhorn

Joined: Dec 27, 2006
Posts: 18
When you request a JSP, the server renders html according to your JSP code, this happens before the result is sent to your browser.

When the result html reach your browser, the browser may execute Javascript code according to events. This happens on your desktop client machine.

So, unless you are talking about explicitly running serverside javascript code (that really has nothing related to controlling display elements / dom), the answer is no: JSP runs on the server before, then Javascript may run on the client.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I call a javascript method from JSP
 
Similar Threads
JSP to Servlet call
how to call a java method from javascript
Iterating using forEach
Calling javascript function in js file from JSP
How can i call jsp from javascript