How to redirect webpage by Lotus Notes java agent?

北战南征 提交于 2019-12-06 14:57:44

问题


Users comes to a page by using following URL:

http://myswerver/mydb.nsf/myagent?OpenAgent

Now I want this Java agent check something in the db and if it meets some conditions then redirect user to another page. If not - load main page that is build by myagent. Here is my agent code:

PrintWriter pw = getAgentOutput();

if(myvar == 1){
    pw.flush();
    pw.println("Content-Type: text/html");
    pw.println("<html><head>");
    pw.println("<script>location.href=\"http://www.mypage.com\"</script>");
    pw.println("</head></html>");
}        

The problem that it loads agents' page everytime even it redirects then. I do want to redirect immediately


回答1:


The solution is much easier: Whenever you want anything to redirect in Lotus Notes in the web, then you simply "print" the redirection url in brackets. Your code can be simplified like this:

PrintWriter pw = getAgentOutput();

if(myvar == 1){
    pw.flush();
    pw.println("[http://www.mypage.com]");
}  

This will instantly redirect you to the url without visibly loading the "agent- page" first.

This would work in LotusScript- Agents as well as

print "[http://www.mypage.com]"


来源:https://stackoverflow.com/questions/33002200/how-to-redirect-webpage-by-lotus-notes-java-agent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!