wood burning stoves 2.0*
The moose likes JSP and the fly likes how to run java script in a jsp before processing a method in scriplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "how to run java script in a jsp before processing a method in scriplet" Watch "how to run java script in a jsp before processing a method in scriplet" New topic
Author

how to run java script in a jsp before processing a method in scriplet

hemanth suram
Greenhorn

Joined: Nov 20, 2010
Posts: 2
Hi All,

I have a jsp. I need to run a java script in body on load. Here in my jsp i have to do a lot of process by calling a method in a bean. The problem is, my script is running after completing the java process. But, i need run this process before calling this method. How can i do this?
Jagdish Hatagale
Ranch Hand

Joined: Apr 07, 2010
Posts: 33
call the java script method in form tag with onload action so that java script will call at page loading.


Regards
jagdish Hatgale
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

That still won't work, since the HTML page is only sent to the client after the code on the page has finished.

You will need to move the method call outside your JSP page to a servlet or another JSP page. Your onload script should then call this servlet / JSP page (through AJAX).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
jQuery in Action, 2nd edition
 
subject: how to run java script in a jsp before processing a method in scriplet
 
Similar Threads
jsp control problem
Problem with image on page load
Do I need to add CLASSPATH/PATH to run java codes in a script ?
questions about Process and Runtime()
boolean need_ of_ vbscript_in_jsp()