aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Can I call a Servlet from Javascript after running local code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Can I call a Servlet from Javascript after running local code?" Watch "Can I call a Servlet from Javascript after running local code?" New topic
Author

Can I call a Servlet from Javascript after running local code?

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1054
I need to run some client script before (or after) posting to a Servlet from a JSP page.
Can this be done?
I tried to include a javascript tag in a JSP page and it didn't load.
Thanks in advance.
-- Mike
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
If you want to run some js before submitting the page (say validation), you can implement the onSubmit function of the button that calls the page. Return true if you want the submit to occur and return false if you do not.
If you want to run some js after the page has been returned by the server, implement the onLoad method of the <body> tag.
The browser does not know and does not care if you use JSP, ASP, PHP or whatever else you can think of. If just gets content (usually HTML) back from the server and renders it.
If you are using the <SCRIPT language='javascript'> tag and it is not working, verify the path of the file you specify is corrrect. That will also cause the problem.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1054
Thanks!!!
-- Mike
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Again, nothing to do with servlets.
I'm moving it to the HTML forum in case someone does a search in that forum for a similar problem.
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I call a Servlet from Javascript after running local code?