Jump to content
Sign in to follow this  
bigjo

call a hidden jsp file from a html page

Recommended Posts

Hi, I have a html page (build with xml en xsl). I want to update my database when someone visits the page with the date and url page. I want it to be done when someone visits the page. I want to get track on how many times a page has been visited and when. The user don't have to click on anything, it has to be stored when the page is opening. I thought to do it to add a javascript that update the database, but it is not a good idea because javascript is client based. So I thought a could call a jsp file (where the code is written to update the database) when the html page loads.The problem is that I don't know how to call the jsp file, without loading it in the browser. I find something like this:

<script language="JavaScript"> function updateStats(){ var jspcall="url.jsp" window.location.href=jspcall } </script> 

and then I tried with

<body onload="updateStats()"> 

But then ofcourse the page is loaded. Someone an idea how I could do it properly?

Edited by bigjo
  • Like 1

Share this post


Link to post
Share on other sites

Try this code.. HTML code:<head><script src="hidden.js" type="text/javascript"></script><.head><body onload="create()"></body> Create a java script file and write below script: var xhr;function create(){if(window.XMLHttpRequest)xhr=new XMLHttpRequest();else if(window.ActiveXObject)xhr=new ActiveXObject("Microsoft.XMLHTTP");}add this to d function for action listener.var url="yourown.jsp?num1="+num1.value+"&num2="+num2.value; xhr.open("GET",url,true); xhr.send(null); U can write ur own code in 'yourown' jsp file.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×