Hi All,
I am trying to connect to another website from my jsp page to get some info - and I am using Jakarta HttpClient to do this.
Unfortunately as soon as I import the package with:
<%@page import=" org.apache.commons.httpclient.HttpClient"%>
I get the following error:
An error occurred at line: 18 in the generated java file
Only a type can be imported. org.apache.commons.httpclient.HttpClient resolves to a package
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:98)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:244)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:276)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:162)
I have browsed other forums and found the following solution:
"I finally found time to verify this. This occurs when you add a jar directly to the Java Build Path instead of adding it as a J2EE Module Dependency (via the project Properties page by the same name) or copying the jar to the project's WEB-INF/lib. Either of these approaches includes the jar in the webapp's WEB-INF/lib when the project is published to a server or exported as a war file. Adding the jar directly to the Java Build Path implies that the server will supply this jar via something like Tomcat's "shared/lib" feature. The errors are the result of not including the jar in the webapp, so the classes are not present and the imports in the JSP are assumed by default to be packages."
I have both commons-httpclient.jar and commons-logging.jar in my WEB-INF/lib folder, but I still get this error. (They are also both in the CLASSPATH global variable) but I still get this error. Any ideas on what my problem could be?
Thanks,
Richard