Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mike London
Ranch Hand
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1192
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!!
-- Mike
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic