Forums Login/signup

Sent data to different Application servlet

+Pie Number of slices to send: Send
Hi Friends,

"I want to send some parameters to a servlet which is in different web application"

I am sorry, gone through many threads on this but in most of them are given solutions to share data in the same application using headers/request attributes etc.

So please give me a solution how it is possible between web applications.

Here how am trying now...

In Application1 , Servlet 1 :

response.setHeader("Key","value");
response.sendRedirect("New Application URL");
In Applicatino2, Servlet 2:
request.getHeader("key")

But it is not giving the header which am sending.

So please let me know where am wrong help in this.
thanks in advance.

+Pie Number of slices to send: Send
The best way will be to set the query string, like:


and in other app, access it like:

+Pie Number of slices to send: Send
Sagar,

Thanks for your reply, but i do not want to append the parmeters.

+Pie Number of slices to send: Send
Header fields are for the browser, so that they can underrated and process the response accordingly. So I don't think this header thing gonna work.

There are only two methods for your requirement:
  • Query string.
  • Session object, if both app are in same context
  • +Pie Number of slices to send: Send
    How is the exact flow of control? Who is the client and who is the server for either request?
    +Pie Number of slices to send: Send
    Here is the flow.

    App1[JSP->Servlet1] -------------->App2[ servlet2]

    Both applicaiton are developed in java. From the jsp i will input values..i read them and have to send them Servlet2.

    I don want to send directly from JSP -> servlet2 and I dont want to append input values to URL.


    +Pie Number of slices to send: Send
    So servlet 1 calls servlet 2; should the output of servlet 2 go back to the browser, or should servlet 1 do something with the output of servlet 2 and then send a response back to the browser?
    +Pie Number of slices to send: Send
    Once the request is sent to App2/Servlet2 then no reply is expected back to App1/Servlet1.

    But my testin purpose am trying to display the all headrs from servlet2....there i could not see the headers which I set in Servlet1.

    +Pie Number of slices to send: Send
    A client-side redirect causes a 2nd request from the browser to the 2nd server - with a new set of headers that are unrelated to the headers used in the 1st request. You may wish to read up on HTTP's request/response mechanism and how a client-side redirect works in your favorite servlet/JSP book/tutorial.
    +Pie Number of slices to send: Send
    Thanks Ulf,

    If this mechanism is a client side redirection does sent new set of request,response then ok ...my headers are not sent. Then please tell me is there any other way to send set of parameters as part of HTTP etc.

    +Pie Number of slices to send: Send
    Servlet 1 can use the HttpURLConnection class (or, easier to use, the Apache HttpClient library) to make a call to servlet 2.
    +Pie Number of slices to send: Send
    Thanks Ulf,
    I gone through some of the examples with HttpClient, Here it used to have a sessino with other applicaiton.

    but i just want to send some parameters either as parameters or headers from Servlet1 --> Servlet2.

    Please help me with some code lines .....

    +Pie Number of slices to send: Send
     

    I gone through some of the examples with HttpClient, Here it used to have a sessino with other applicaiton.


    I don't understand what that has to do with this topic.

    but i just want to send some parameters either as parameters or headers from Servlet1 --> Servlet2.


    The HttpClient examples show how to do that, don't they? What do you have so far, and what's still missing to make it work?
    +Pie Number of slices to send: Send
    Thanks Ulf , I got it. I got it in an exmaple, but getting some error..will solve it.

    Thanks for all your help.


    reply
    reply
    This thread has been viewed 1803 times.
    Similar Threads
    Web app design confusion
    My first Java Web project and database patterns questions.
    is it possible to distribute a servlet based application?
    Communicating With A Remote Servlet
    Problem with posting data from one servlet to another servlet in a different application
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Jun 30, 2025 11:41:19.