i want to run a method in servlet when client finished onload webpage without need to rewrite or reload the current webpage.i try to use javascript onload event, but need to rewrite back the current page.
how to know a request come from web browser beside using user agent.
I have no idea what you mean with “but need to rewrite back the current page”, but to the point, you can just use
XMLHttpRequest(Ajax) to send a HTTP request at an arbitrary moment in JavaScript.Here’s a kickoff example which utilizes jQuery so that the crossbrowsercompatible boilerplate Ajax code is minimized by a factor over 10 times, just drop it somewhere in the
<head>of your JSP/HTML document:It will invoke the
doGet()method of a servlet mapped on/servletURL.