Note:
Servlet residing in, say "ServerA" I.P(121.12.12.13)
Jsp in "ServerB" I.P(131.13.13.14)
I have above scenario where I want to send some parameters/values from servlet("in ServerA") to a jsp ("in ServerB") so that jsp will process the data and return the data as a list ("java.util.list") to servlet ("in serverA").
Make a request to the remote web app using URLConnection, or HttpClient, or some other way to initiate requests under program control. Pass data as request parameters.
dileep keely wrote:Note:
Servlet residing in, say "ServerA" I.P(121.12.12.13)
Jsp in "ServerB" I.P(131.13.13.14)
I have above scenario where I want to send some parameters/values from servlet("in ServerA") to a jsp ("in ServerB") so that jsp will process the data and return the data as a list ("java.util.list") to servlet ("in serverA").
Can some one please provide a suggestion?[
Sounds like a use case for a web service method / EJB method instead of a servlet -> JSP communication. The flow of control also seems to be in reverse
Also, since the pages / servlets are in different servers, sharing objects through some sort of scope is not possible.
use the session tracking for sending values from jsp to servlet or servlet to jsp
1.hidden parameters
2.cookies
3.sessions
dileep keely
Ranch Hand
Joined: Jun 28, 2010
Posts: 91
posted
0
I believe that I can do it as per the suggestion from "Bear".
Before going to test with a remote server,I started trying with the abstract class URLConnection in different web-applications in the same server.
But,when I tried to getInputStream of a jsp from a servlet ,I get the processed data from jsp including the <html> tags.
You're going to have to parse the HTML and extract the information you need from it.
Obviously this isn't a good thing to do, but that's what you have to expect from such a design. If you want something which returns specific information then (as Deepak suggested) the design should have been some kind of web service.
dileep keely wrote:I get the processed data from jsp including the <html> tags.
Of course. You'll get whatever the remote server returns as the response.
If you want something different, do you have control over what the remote server creates as the response? If not, can you get what you need by parsing the returned markup?
[Edit: ha! Paul beat me to the punch!]
dileep keely
Ranch Hand
Joined: Jun 28, 2010
Posts: 91
posted
0
yes Bear,I do have a control over the remote server response completely(code).
dileep keely wrote:Then you can modify the code to send only what you want. if you don't want HTML markup, don't send it.
It means to avoid using html code tags in remote jsp is it.
If you're not sending HTML or XML, I would avoid using JSP entirely. If you use a servlet, you can send a text/plain response that contains only your data.
OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower