问题
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