Jump to content

JSP Scriptlet in JavaScript SetTimeout


Recommended Posts

Hi!I want to do something like thissetTimeout('<%session.removeAttribute("att");%>',20000)this things gives error.Alternatively, I defined a JavaScript function, and in that, did that session remove thing, likefunction removeAtt(){ <%session.removeAttribute("att");%>}setTimeout('removeAtt()',20000)In this case, attribute is removed without timeout.Even in the following case, alert appears at the given time, but remove statement executes without timeout interval.function removeAtt(){ <%session.removeAttribute("att");%>}setTimeout('removeAtt(),alert(\'This is alertt\')',20000)Any help!!!Thanks & Best Regards.Muhammad Asad Ullah

Edited by Muhammad AsadUllah Bhatti
Link to comment
Share on other sites

You need to understand that server-side code is completely independent from the client-side code. It runs before the page gets sent to the browser.Look at the source code of your page after it gets sent. It would look like this:


Or like this:

function removeAtt(){}setTimeout('removeAtt()',20000)

It's because the session.removeAttribute() function doesn't print anything.

Link to comment
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

  • Create New...