Dragos
Dragos

Reputation: 2981

Making a request from servlet

I am trying to make an application connect to Google Plus API, but for this I need to have some request parameters kept secret. This is why I cannot just make a simple ajax request or create a form with hidden inputs. My solution is to make a request to a servlet and from there, with HttpClient another request to Google. Here is the problem:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            System.out.println(TestClass.makeRequest());
}

TestClass.makeRequest() creates the HttpPost object, gets the response and returns a String.

When I run this on the server, I get this error:

java.lang.ClassNotFoundException: org.apache.http.HttpEntity

I do not understand why this happens. Can you provide a solution please? Any other methods for transmitting hidden parameters in a request are helpful.

Upvotes: 1

Views: 161

Answers (1)

Reimeus
Reimeus

Reputation: 159754

It appears that while you have all the necessary jar files in your build path, they are not deployed with your servlet. These 2 operating environments are different.

To make the 3d party libraries available to your servlet classes make sure to that httpcore-4.0.1.jar and all other dependent jars are deployed to the

WEB-INF/lib

directory of your web app.

Upvotes: 1

Related Questions