clo1
asked on
Response in servlet
My client is going to access my servlet function with a specified URL, there is a parameter call RETURN_URL, and he ask me to return the query result in XML format to this RETURN _URL, can anyone give me a clue for how to do it? Thanks !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You don't return a URL the Servlet will write a response:
OutputStream out=response.getOutputStre am()
out.println("<html>");
out.println("<head>");
out.println("<title>Sample Output</title>);
out.println("</head>");
out.println("<body>");
out.println("Now is the time for all good men to come to the aid of their country");
out.println("</body>");
out.println("</html>");
OutputStream out=response.getOutputStre
out.println("<html>");
out.println("<head>");
out.println("<title>Sample
out.println("</head>");
out.println("<body>");
out.println("Now is the time for all good men to come to the aid of their country");
out.println("</body>");
out.println("</html>");
ASKER
But the client does provide a URL for me to return, which is different from the request one. For example, his requesting URL is like this:
http://www.mysite.com/servlet/query?return_url=www.abc.com&keyword=something
So how do I return the result to the return_url parameter, i..e. www.abc.com? Thanks !
http://www.mysite.com/servlet/query?return_url=www.abc.com&keyword=something
So how do I return the result to the return_url parameter, i..e. www.abc.com? Thanks !
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The best is to use URLEncoder and encode it. I hope you can form a protocol with the client that he can decode it at the other end.
http://www.javaalmanac.com/egs/java.net/Post.html
Also have a look at the "Related Examples".
http://www.javaalmanac.com/egs/java.net/Post.html
Also have a look at the "Related Examples".
Redirect will redirect the CLIENT to the URL. Then the client will get the request from the URL.
If you want to SEND data to the URL use mayankeagle's suggestion.
You will still need to send a response to the client, though. Just send the remote servers response if it makes sense, or just send "success" or "Failure" pages.
If you want to SEND data to the URL use mayankeagle's suggestion.
You will still need to send a response to the client, though. Just send the remote servers response if it makes sense, or just send "success" or "Failure" pages.
> Redirect will redirect the CLIENT to the URL. Then the client will get the request from the URL.
>
>If you want to SEND data to the URL use mayankeagle's suggestion.
You can still send data with a redirect.
>
>If you want to SEND data to the URL use mayankeagle's suggestion.
You can still send data with a redirect.
Yes, you can add additional parameters to the redirect URL and the client will send the additional parameters to the redirect request.
I'd say split the points between all participants.
How about the URLEncoder?
Ah, a max 2-way split.
ASKER