• Post Reply Bookmark Topic Watch Topic
  • New Topic

Send.do + Receive.do servlets  RSS feed

 
Alba Garcia
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I think that I was experienceid in Servlets but know I realised that I am not.

This is the casuistry:

1. I have 1 Servlet Send.do that send a GET request to an Url and when it gets the response it makes a forward to another servlet Receive.do

2. In the Receive.do I need to wait until it receives a GET request from another app that send it a parameter and write the response in a JSP later.


My problem is that when Send.do servlet forward to Receive.do, Receive.do understand that request like a normal GET request so at this moment Receive.do forwart to the JSP but without having the parameter. I mean, I loose the real one GET request parameter that occurs in the next GET request.

How could avoid that?

I would like to skip the first GET request from Send.do to Receive.do and only process the second and real GET request from the other app.


Any piece of advice would be apreciated.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's quite confusing. Your Send.do servlet receives a request from somewhere and when it does, it sends a request to a different (?) application, ignores the response from that application, and forwards to Receive.do. That sort of makes sense, although sending a GET request to an application and ignoring the response seems rather useless to me.

However this constitutes sending a request to Receive.do. However there's apparently another request which is supposed to come from somewhere else? From another application? Is that the application which Send.do communicated with, or something else? Did the original request come from that application or something else?

This is probably completely wrong because I'm totally confused about all of these requests and applications, but why not just have Send.do not forward to Receive.do? Then when the actual request is sent to Receive.do with the parameter, Receive.do can function in the normal way.
 
Alba Garcia
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry!! I forgot saying that Send.do servlet receives a request from a button in this JSP:


You are rigth, Send.do sends it to a different app (an HTTP listener channel in Mirth Connect app). When the HTTP Listener channel receive the request it triggers a serie of petitions that ends in one HTTP Sender channel that makes a GET request (http://localhost:58080/decision-support/Receive.do) sending the cdsOutput parameter.

So Send.do and Receive.do communicates with the same app (Mirth Connect) Send.do makes a GET request that triggers a process and Receive.do receive a GET request with a parameter that should be printed at the end of the chain.

I have followed your advices and Send.do is now like that:


and Receive.do


But when the Receive.do Servlet receives the request browser can't show the result any more.

What am I doing wrong?

Thanks in advance!





 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if I understand it correctly, there is a chain of requests which looks like this:

Browser ---> Send.do ---> Mirth ---> Receive.do

And you want the response from Receive.do to appear in the browser which sent the original request? If so then you need the responses to go like this:

Receive.do ---> Mirth ---> Send.do ---> Browser

You already have the first of those three working. The second? You'll have to investigate to see if that's happening. And as for the third, remember how I mentioned that Send.do was ignoring the response from Mirth? It should be reading the output from that HttpURLConnection and sending it as its response, rather than forwarding to Receive.do.
 
Alba Garcia
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
¿Do you think that it can be possible?

Receive.do ---> Send.do ---> Browser

 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The servlet can only send the response to whatever requested it. That's a fundamental principle of HTTP.
 
Alba Garcia
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so firstly how can I make the response go from Receive.do to Mirth. Which is the best method?



where location is an HTTP url where Mirth is listening?


Thanks!!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alba Garcia wrote:OK, so firstly how can I make the response go from Receive.do to Mirth. Which is the best method?


No. You didn't understand what I wrote, I think. The response will ALWAYS go to Mirth no matter what you do. So the best method is to send the response and do nothing else.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!