简体   繁体   English

在 JSP 上使用第 3 方 Java 库

[英]Using 3rd Party Java Libraries on JSP

How can I use 3rd party libraries like Twitter4J on JSP?如何在JSP上使用 Twitter4J 等第三方库?

It's a bit sick, but can you not just inline the appropriate Java in your JSP?这有点恶心,但你能不能只在你的 JSP 中内联适当的 Java ?

<%
   // 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.确保 Twitter4J jar 及其所有依赖项都在您的 WEB-INF/lib/ 文件夹中。 Then, give some serious thought to not doing this in a JSP if at all possible!然后,如果可能的话,认真考虑不要在 JSP 中这样做!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 来自第三方的网络响应,使用其给定的API,C# - webresponse from 3rd party, using their given API, C# 如何在JSP中保护第三方Taglib - How to secure 3rd-party taglib in jsp 从HTTPS重定向到第三方HTTP页面,而不会出现证书错误 - Redirect to a 3rd party HTTP page from HTTPS without the certificate error 可以在我的网页中打开第三方网站的表格以及我网站上的一些资料 - can a 3rd party site's form be opened in my webpage, along with some material from my site 使用Java EE 7的JSP中的自定义标签库 - Custom tag libraries in JSP with Java EE 7 如何在jsp代码中导入java库? - How to import java libraries in jsp code? 当其他jsp的javascript第3次或第4次访问时,在index.jsp中设置的会话变量返回null - Session variable set in index.jsp returns null when accessed 3rd or 4th time by javascript in others jsp's 通过3rd-party-Servlet生成的表单将参数传递到下一个JSP页面 - Passing parameter to next JSP page by a 3rd-party-Servlet-generated form 如何在 session 中存储一个值,以后必须根据来自第 3 方站点的回调请求访问该值? - How do I store a value in session that has to be later accessed upon a callback request from a 3rd party site? 使用JSP和Java的WebApp - WebApp using JSP and Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM