How can I send my response and request object from a jsp file to a servlet by code? I don't want to submit a form or so.
I tried it with:
response.setRedirect("my page"):
But then it says:
Exception in thread "main" org.apache.http.client.HttpResponseException: Moved Temporarily
at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:68)
at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:945)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:919)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:910)
at com.xx.xx.client.Client.sendPOSTRequest(Client.java:185)
at com.xx.xx.client.Client.main(Client.java:46)
As clarification: I have a client that sends a post request to a JSP file. This JSP file parses a file and puts the needed information into the session. I want to call a servlet from this jsp file to add something into the database. I think this error code is thrown by this line String responseBody = httpclient.execute(httppost, responseHandler);