• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to pass parameters from one container to other container using sendRedirect

 
Vasu Manda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have strucked with one problem while using res.sendRedirect(). I have to use sendRedirect only.

Problem is, I have two containers A,B. So that I have to pass one paramenter from A container to B container.

Basically when we use res.sendRedirect() it loose the previous details once request is done.

How to pass the parameter from A container to B container by using sendRedirect().

Can any body help us.

thanks in advance..
Vasu
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the two containers hosted in the same subdomain? If so, you might be able to use cookies.

How sensitive is the data you want to send?
 
Vasu Manda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sharad Agarwal:
Are the two containers hosted in the same subdomain? If so, you might be able to use cookies.

How sensitive is the data you want to send?


Thanks Sharad Agarwal for your fast reply.

Actually both are different domains. Data is sensitive actually.

Requirement that not to use cookies.

Please let me know

Thanks
Vasu
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not totally sure I understand the requirement. Lets say this is your situation:
1. Browser X makes POST request to container A with parameter P
2. Container A performs processing and produces information I
3. Container A wants to redirect the request to Container B

What data does A want to share with B? Is it P, I or both?
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Container A:
sendRedirect("http://containerB?parameters=myencryptedparameters");

Container B:
Map parameters = decryptAndParse(getParameter("parameters")[0]);
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Vasu MR",

There aren't may rules that have been put into place here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
Vasu Manda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will explain clearly.

I have the container A ,it has i = 10 value.

I have other container B. Now I have to send the value i = 10 which is value of the container A to container B.

I have to use sendRedirect.

If i used sendRedirect, it loose the previous request, it means it creates fresh request. How it is possible in my case.

Hope it is clear now.

Thanks
Vasu
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have any security problems by passing the info as query string??

I could see easy possibility is query string.
 
Vasu Manda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not able to pass the value bye req.getParameter("")
 
Nathan Russell
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds almost exactly like the problem I am having ( http://www.coderanch.com/t/360535/Servlets/java/POST-ing-parameters-another-JSP ) - passing a paramter from one JSP to another using POST

Using a cookie is invasive (some people don't like / trust them, so you cant rely on them as a means to ensure your application works); and passing the parameters on the query string (a HTTP GET) whilst would work, looks messy, exposes some of your 'inner workings' and may present a security issue.

Vasu - if you read my thread, you will see the bodge I have implemented to acheive this - it works, but is really nasty (uses a HTML form with hidden fields which are the params to pass, action of the form is the target jsp file, javascript 'auto' submits the form)
Very nasty, but does work.
Surely there is a way of redirecting to another page, and using POST to pass variables ?
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vasu Manda:

I have other container B. Now I have to send the value i = 10 which is value of the container A to container B.

I have to use sendRedirect.

If i used sendRedirect, it loose the previous request, it means it creates fresh request. How it is possible in my case.


Check out D Rog's solution to your problem. If 'i' is not sensitive, there is no need to encrypt it. Else use encryption as D Rog suggested. There is, of course, the small matter of sharing the private key between containers A and B in that case. Let us know if that is an issue.

An alternative solution could be for container A to serialize 'i' into a shared database on the server from which container B could retrieve it. But that is more involved than D Rog's solution.
 
Vasu Manda
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D Rog /sharat aggrawal

can you please explain bit clearly.

before sendRecired("http://containerB?parameter=enc..

Please write and explaing bit clearly.

that would help me lot.

thanks
vasu
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those are called query string variables or query string parameters.
Everything in the URL after the '?' character is treated as a set of name value pairs.
The names and values are separated by an '=' character.
The pairs are separated by an ampersand '&' character.

To pass a parmeter named "i" with a value of "10" and a parameter named "j" with a value of "11"you would construct the following string:
http://www.somedomain.com/mypage.jsp?i=10&j=11

You can then retrieve these with request.getParameter("i").....

-----------------------------

By the way, if you use:
METHOD="GET" in your form tag, the browser will automatically tack these parameters to the end of the querystring for you.

The following chapter from "Core Servlets and Java Server Pages" covers HTML form faily well.
http://csajsp-chapters.corewebprogramming.com/CSAJSP-Chapter16.pdf
[ June 07, 2005: Message edited by: Ben Souther ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!