Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting a Get Request into Post Request

 
Anks Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

My Application gets loaded from a hyperlink in a portal where parameters required by my applications are sent in a query String( Get request). Now after using those parameters in my business logic, My page which gets rendered has that query String still in URL. I am using requestDispatcher to render the response. I cant use sendRedirect as i need server side response because of my application requirements.

I dont want this query string in URL as it has some sensitive data.

So i want to convert my Get Request to POST before it hits the business logic.

Is it possible? If yes than please let me know the wayout.

I do not have access to modify portal so i cant make it a POST request on initial hit.

Thanks
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Convert?

Just let the portal invoke a POST request instead of a GET request using a form.
 
Anks Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any other workaround to implement this is also welcome. Please help
 
Anks Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I have said I dont have access to Portal system. I need to handle this in my own app only.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That´s a pity.

You need to invoke a redirect after GET to get rid of the query parameters. You may consider to store the data temporarily in session and remove it after the redirect.
 
Anks Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also My Application is called through a hyperLink in portal and hyperlinks are inherently GET.
 
ashirvad jain
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I think you can try with filter.
I was reading filter, then came to know that you can process your request before submitting to Business Logic,
and that is also not visible to cleint or in URL.
You can work aroud filters. Maybe can help you.
Regards.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the browser sent a GET, then nothing that's done on the server will convince it otherwise, and the parameters will be shown. Filters can do nothing about this. You'll need to do a client-side redirect.
 
Anks Gupta
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bauke... Redirect worked for me
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anks Gupta wrote:Also My Application is called through a hyperLink in portal and hyperlinks are inherently GET.

Uh yes. I didn't say that you need a hyperlink for post. I mentioned about a form.

At any way, you need to invoke a redirect. That's all. To transfer variables to the redirected request, temporarily make use of the session.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anks Gupta wrote:Thanks Bauke... Redirect worked for me

Good work. You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic