java - response.setheader("Refresh", "0") not working -


i trying refresh webpage when user session has expired or connection not active. tried lot of codes didn't seem work. last code used

if(session.getattribute("connection") != null && !session.getattribute("connection").equals("")){             conn = (dbconnection) session.getattribute("connection");             if(conn == null){                     response.setcontenttype("text/html");                     response.setheader("refresh", "3");                     return;                 }             }else{                 response.setcontenttype("text/html");                 response.setheader("refresh", "3");                 return;             } 

i tried response.sendredirect() , request.getrequestdispatcher.forward() didnt work well. servlet being called javascript expects json object.

you cannot directly execute command on client directly servlet. notice http protocol relies on requests client , responses server.

so if no request made client, nothing can send server (simply because server doesn't have request response )

i know have seen functionality , yes can done. not in manner. ajax best bet here... (sending requests @ regular intervals , getting response server etc)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -