This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing data from servlet/jsp

 
dileep keely
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?[
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
venkatesh polneedi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Output:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
CTlog
</body>
</html>

How to avoid the tags from processing.?
 
Paul Clapham
Sheriff
Pie
Posts: 20955
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes Bear,I do have a control over the remote server response completely(code).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you can modify the code to send only what you want. if you don't want HTML markup, don't send it.
 
dileep keely
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It means to avoid using html code tags in remote jsp is it.


 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic