This is the code which is use for login in facebook but it is go to the finaly block and show my facebook link in browser. i am show from which it go to the finaly block in program. how to login without open browser this example is yack from http://code.google.com/p/facebook-java-api/wiki/Examples
try{
MDC.put(ipAddress, req.getRemoteAddr());
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session = request.getSession(true);
IFacebookRestClient<Document> userClient = getUserClient(session);
if (userClient == null) {
logger.debug("User session doesn't have a Facebook API client setup yet. Creating one and storing it in the user's session.");
userClient = new FacebookXmlRestClient(api_key, secret);
session.setAttribute(FACEBOOK_USER_CLIENT, userClient);
}
logger.trace("Creating a FacebookWebappHelper, which copies fb_ request param data into the userClient");
FacebookWebappHelper<Document> facebook = new FacebookWebappHelper<Document>(request, response, api_key, secret, userClient);
String nextPage = request.getRequestURI();
nextPage = nextPage.substring(nextPage.indexOf("/", 1) + 1); //cut out the first /, the context path and the 2nd /
logger.trace(nextPage);
boolean redirectOccurred = facebook.requireLogin(nextPage);
if (redirectOccurred) {
return; //from this pt. send to finaly block and open my facebook page
}
redirectOccurred = facebook.requireFrame(nextPage);
if (redirectOccurred) {
return;
}
long facebookUserID;
try {
facebookUserID = userClient.users_getLoggedInUser();
} catch (FacebookException ex) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while fetching user's facebook ID");
logger.error("Error while getting cached (supplied by request params) value "
+ "of the user's facebook ID or while fetching it from the Facebook service "
+ "if the cached value was not present for some reason. Cached value = {}", userClient.getCacheUserId());
return;
}
MDC.put(facebookUserId, String.valueOf(facebookUserID));
chain.doFilter(request, response);
} finally {
MDC.remove(ipAddress);
MDC.remove(facebookUserId);
}