Server side redirect

We had a great get together yesterday at the Geek Meet and many technical discussions where taking place not to mention all new connections that where made. Extremely fun and very well organized by Johan Molin at E-Kakan.One small subject that came up where how to do a server side redirect from an agent. There are two ways to do this, I call them internal or external. If you want to redirect the web browser to another host, then you will go with the external solution that sends an 302 to the user.The internal way is completely transpararent to the user. Here are a code examples in java:

1
2
3
4
5
6
7
8
9
10
11
12
13
import lotus.domino.*;
import java.io.*;
public class JavaAgent extends AgentBase {
    public void NotesMain() {
        try {
            PrintWriter pw = getAgentOutput();
            pw.println("[[/demo.nsf/endPoint?openpage]]");
            }
        catch(Exception e) {
            e.printStackTrace();
        }
    }
}

6 Comments

Fredrik StöckelMay 25th, 2007 at 10:58

Nice, and if you want to use POST as method?

Johan KänngårdMay 25th, 2007 at 11:26

I have had big problems with internal redirects that sometimes works, sometimes not, and just gives some strange 500 server errors. I haven’t had time to look into the source of that problem though, it might exist a solution. Have you successfully used those internal redirects at all time?

JocheMay 25th, 2007 at 12:13

I have used redirects for over ten years. From the beginning mostly in $$return fields but the last years more and more in agents. It’s especially handy to use when the agent builds up a complex argument list that’s used for opening a web view.

I have never had any problems with this.

Tomas NielsenJune 2nd, 2007 at 08:10

Johan, could it be the page you are redirecting to is causing the 500?

Fredrik, do you mean having the redirect in $$Return?

Johan KänngårdJune 13th, 2007 at 22:14

No, that was not the reason. But I guess I could try again, last time was in R5 :-P

Fredrik StöckelJune 25th, 2007 at 16:17

Tomas, no i mean that I want the redirect METHOD to be a POST rather than a GET. But that was before I examined the http headers and how the redirect actually works.

Leave a comment

Your comment