This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 19674
    
  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