<%
// This should really be in a servlet
// Twitter4J code from their example
Twitter twitter = new TwitterFactory().getInstance();
List<Status> statuses = twitter.getFriendsTimeline();
System.out.println("Showing friends timeline.");
for (Status status : statuses) {
System.out.println(status.getUser().getName() + ":" +
status.getText());
}
%>
确保 Twitter4J jar 及其所有依赖项位于 WEB-INF/lib/ 文件夹中。然后,认真考虑一下如果可能的话不要在 JSP 中这样做!
It's a bit sick, but can you not just inline the appropriate Java in your JSP?
<%
// This should really be in a servlet
// Twitter4J code from their example
Twitter twitter = new TwitterFactory().getInstance();
List<Status> statuses = twitter.getFriendsTimeline();
System.out.println("Showing friends timeline.");
for (Status status : statuses) {
System.out.println(status.getUser().getName() + ":" +
status.getText());
}
%>
Make sure that the Twitter4J jar and all its dependencies are in your WEB-INF/lib/ folder. Then, give some serious thought to not doing this in a JSP if at all possible!
发布评论
评论(1)
这有点恶心,但是您不能在 JSP 中内联适当的 Java 吗?
确保 Twitter4J jar 及其所有依赖项位于 WEB-INF/lib/ 文件夹中。然后,认真考虑一下如果可能的话不要在 JSP 中这样做!
It's a bit sick, but can you not just inline the appropriate Java in your JSP?
Make sure that the Twitter4J jar and all its dependencies are in your WEB-INF/lib/ folder. Then, give some serious thought to not doing this in a JSP if at all possible!