Raazan Kurunju
Raazan Kurunju

Reputation: 89

hide parameters in jsp while redirect to php page

I have a jsp page with a redirect button/link. I need to redirect to a PHP page along with parameters. Now, I need to hide the parameters from the address bar. How is it possible?

For Example:

http://jspsite.com/a.jsp

I need redirect to b.php as:

http://phpsite.com/b.php?user=1234

How can I hide this parameter "user" from the link?

Please help

Upvotes: 0

Views: 357

Answers (2)

developerwjk
developerwjk

Reputation: 8659

The only way to keep the parameter out of the address bar is to send the request as POST, but if you're redirecting then its going to use GET automatically so the parameters will show in the address bar.

So the best you can do is put a form on the page and make the user click it.

You can use a "hidden" input in the form rather than a visible text box.

  <input type="hidden" value="1234" name="user">

But understand that "hiding" the parameter from the address bar and making the input field invisible on the rendered form doesn't mean the user can't see it or change it, because they always can view the source of the form.

Upvotes: 1

Rohan Kumar
Rohan Kumar

Reputation: 40639

If it is a form then you can use POST method, like,

<form action="b.php" method="POST">
   <input type="text" value="1234" name="user">
   <input type="submit" value="Submit" />
</form>

In b.php Page use the variable like,

echo $_REQUEST['user'];

Otherwise use htaccess like,

RewriteRule ^user=[0-9] user/$1 [L,QSA]

Upvotes: 0

Related Questions