Authentication 如何将授权代码从JSP传递到Servlet

Authentication 如何将授权代码从JSP传递到Servlet,authentication,facebook-authentication,Authentication,Facebook Authentication,我已经不知所措了,7个小时还在数 我是FB开发的新手,在将授权代码从JSP传递到Servlet时遇到了一个问题 1.)我在JSP中使用社交插件登录,如下所示 <fb:login-button>Login with Facebook</fb:login-button> FB.Event.subscribe('auth.login', function (response) { window.location = "testservlet"; }); String

我已经不知所措了,7个小时还在数

我是FB开发的新手,在将授权代码从JSP传递到Servlet时遇到了一个问题

1.)我在JSP中使用社交插件登录,如下所示

<fb:login-button>Login with Facebook</fb:login-button>
 FB.Event.subscribe('auth.login', function (response) {
 window.location = "testservlet"; 
 });
String authCode = req.getParameter("code");
3。)但当我试图在Servlet中获取授权代码(以便获取auth.token)时,“代码”为空,请参阅下面我用来检索的代码

<fb:login-button>Login with Facebook</fb:login-button>
 FB.Event.subscribe('auth.login', function (response) {
 window.location = "testservlet"; 
 });
String authCode = req.getParameter("code");

有人能告诉我我做错了什么吗?我肯定我错过了这么简单的事情..或者我正在尝试做更多不必要的事情,提前感谢

我不熟悉Facebook开发,但是关于servlet,通常来说window.location不会带你去servlet。
尝试使用jquery的ajax函数并传递一个“code”参数。执行类似以下操作:

$.ajax({
        url: yourServletPath+"testservlet",
        data:"code="+codevariable,
        dataType: "whatever data type your servlet returns",
        success: function(response) 
        {
          // wtv code to be done
        } 
      });