This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread 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


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: 20078
    
  30

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 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
Have you checked out Aspose?
 
subject: how to run java script in a jsp before processing a method in scriplet
 
It's not a secret anymore!