开发者

In HttpSession session = request.getSession(); Where is the "request" object defined?

Using twitter4j and java, I am trying to use the following code to connect to Twitter. In my java class I have 开发者_C百科the following code.

Twitter twitter = new Twitter();
twitter.setOAuthConsumer(consumerKey,consumerSecret);
RequestToken requestToken = twitter.getOAuthRequestToken();

String token = requestToken.getToken();
String tokenSecret = requestToken.getTokenSecret();

HttpSession session = request.getSession();
session.setAttribute("token",token);
session.setAttribute("tokenSecret",tokenSecret);

I got this code from a tutorial. The problem I am having is with the line

HttpSession session = request.getSession();

Where is the object "request" defined?

My program is a localhost program, entirely in Java. I am trying to learn how to use the Twitter API


That sounds like a question that you should be answering yourself. It looks like your tutorial assumed it was running from a Servlet or JSP, where there's an HttpServletRequest object available that looks like it would fill those roles. The only reason it seems to be used, though, is because the HTTP session is a convenient place to store the oauth token and secret in a webapp. You can put them anywhere as long as you can get them back later.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜