I am writing a
JSP page that connects to another web server to extract some information to be shown on the page. I'm using apache common's httpclient. This is a sample of the code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="org.apache.commons.httpclient.HttpConnection"%>
<%@page import="org.apache.commons.httpclient.params.HttpConnectionManagerParams"%>
<%@page import="org.apache.commons.httpclient.SimpleHttpConnectionManager"%>
<%@page import="org.apache.commons.httpclient.HttpClient"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "fatal");
HttpConnectionManagerParams hcmpParams = new HttpConnectionManagerParams();
hcmpParams.setSoTimeout(3000);
SimpleHttpConnectionManager shcmConnManager = new SimpleHttpConnectionManager();
shcmConnManager.setParams(hcmpParams);
HttpClient hClient = new HttpClient(shcmConnManager);
%>
</body>
</html>
In WTP I can create the JSP without problems or errors, but when I try to run in an Apache server inside WTP I get
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated
servlet error:
Only a type can be imported. org.apache.commons.httpclient.HttpClient resolves to a package
Generated servlet error:
Only a type can be imported. org.apache.commons.httpclient.HttpConnection resolves to a package
An error occurred at line: 12 in the jsp file: /account/login.jsp
Generated servlet error:
HttpConnection cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /account/login.jsp
Generated servlet error:
HttpConnection cannot be resolved to a type
I added the jar file to web.xml as
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>classpath</param-name>
<param-value>c:/JavaResources/commons-httpclient-3.0.1/commons-httpclient-3.0.1.jar</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
Does anyone knows what am I missing or doing wrong?
Thanks