Jump to content

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
Link to post
Share on other sites
  • 4 months later...

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...