How do I make a third party .jar available to my .jsp page?

Posted by Matthew on Stack Overflow See other posts from Stack Overflow or by Matthew
Published on 2010-06-06T17:49:22Z Indexed on 2010/06/06 17:52 UTC
Read the original article Hit count: 306

Filed under:
|
|
|

I'm just starting to learn JSP (and I'm pretty new to Java in general), and I'd like to use JSON-lib with it. I want to make a page something like this:

<%@ page import="net.sf.json.JSONObject"%>
<%
String json = new JSONObject().put("hello", "world").toString();
out.println(json);
%>

I downloaded json-lib-2.3-jdk15.jar and put it in the same directory as the .jsp page. But I get this error

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 6 in the generated java file
Only a type can be imported. net.sf.json.JSONObject resolves to a package

An error occurred at line: 3 in the jsp file: /getCard.jsp
JSONObject cannot be resolved to a type
1: <%@ page import="net.sf.json.JSONObject" %>
2: <%
3: String json = new JSONObject().put("hello", "world").toString();
4: out.println(json);
5: %>
6: 

How do I make the JSONObject class available to my .jsp page?

© Stack Overflow or respective owner

Related posts about java

Related posts about JSON