• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Passing data from servlet/jsp

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?[
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.?
 
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes Bear,I do have a control over the remote server response completely(code).
 
Bear Bibeault
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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


 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
reply
    Bookmark Topic Watch Topic
  • New Topic