aspose file tools*
The moose likes Servlets and the fly likes Converting a Get Request into Post Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Converting a Get Request into Post Request" Watch "Converting a Get Request into Post Request" New topic
Author

Converting a Get Request into Post Request

Anks Gupta
Greenhorn

Joined: Mar 27, 2007
Posts: 21
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

Joined: Oct 08, 2006
Posts: 2458
Convert?

Just let the portal invoke a POST request instead of a GET request using a form.
Anks Gupta
Greenhorn

Joined: Mar 27, 2007
Posts: 21
Any other workaround to implement this is also welcome. Please help
Anks Gupta
Greenhorn

Joined: Mar 27, 2007
Posts: 21
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

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Mar 27, 2007
Posts: 21
Also My Application is called through a hyperLink in portal and hyperlinks are inherently GET.
ashirvad jain
Ranch Hand

Joined: Nov 09, 2006
Posts: 50
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
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
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.


Ping & DNS - my free Android networking tools app
Anks Gupta
Greenhorn

Joined: Mar 27, 2007
Posts: 21
Thanks Bauke... Redirect worked for me
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Oct 08, 2006
Posts: 2458
Anks Gupta wrote:Thanks Bauke... Redirect worked for me

Good work. You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting a Get Request into Post Request