Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8729439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:50:01+00:00 2026-06-13T08:50:01+00:00

How can I send my response and request object from a jsp file to

  • 0

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);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:50:02+00:00Added an answer on June 13, 2026 at 8:50 am

    you can use the RequestDispatcher forward(ServletRequest request, ServletResponse response)

    Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server.

    You can do it like this:

    ServletContext context= getServletContext();
    RequestDispatcher rd= context.getRequestDispatcher("/YourServlet");
    rd.forward(request, response);
    

    UPDATE

    Also note on your code that you have response.setRedirect instead of response.sendRedirect(...) but note that this method will not work as you want it to because it just asks the browser to make a new request to your servlet rather than forward your request and response object to that servlet . See RequestDispatcher.forward() vs HttpServletResponse.sendRedirect() for more info

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Javascript I can send XML string to JSP server (XmlAction.jsp): Javascript Code: var
I want to send array of my own objects to JSP page by request.
I'm using XhmHttp request object to send SOAP request to web services from classic
I can send requests to friends using Multi Friend Request Selector inside my Page
how i can send key from my C# program to external program ? ex:
how i can send sms from asp.net?any idea about it?or any resource through which
Using cURL I can send a GET request with a body. Example: curl -i
I have several sites where users can send me email through an html form
I need to display the data from a servlet in a jsp page. At
Via the tutorial at https://github.com/simplegeo/python-oauth2 , I can create a signed Request object. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.