Jump to content

JSP Scriptlet in JavaScript SetTimeout


hussainian

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

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:

setTimeout('',20000)

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...