How to change GET to POST - post

I have one web application running on Struts. User is hitting below url directly from browser -
http://:/Test/servlet.do?name=XX&address=YYY
By default this request is submitted as GET by the user. Now my question is
1) how do I change user request to POST?

Use JQuery post or ajax methods, using an empty form with hidden keys.

There are plenty of browser add-ons that will let you send your request as POST (such as DHC by Restlet and Advanced REST client for Chrome)

Remember GET is inside the ans is set into links. POST are usually done by , or GET is possible too. So hitting a URL or link as you said is not possible to do over html, use PHP or Jquery so have it GET instead .

Related

How to make actions by GET request instead of POST request in Vimeo API?

Can I make any action like post comment, upload video, etc.. by send a GET Request instead of POST in Vimeo API? like graph facebook api, can post an comment by GET Request with method parameter
Simply put, you can't. Our API is RESTful and does not allow this type of behavior. If we document an endpoint, like uploading a video, as POST, you can only do that with a POST.
Likely not in the vein of StackOverflow, but this post is oddly relevant here.
https://twitter.com/rombulow/status/990684453734203392?lang=en
In sum: GET requests should be idempotent by definition. By defining a GET request to perform some action on the backend, you may run into issues with browsers that preload content based on page links. A sample manifestation of this would be a garage door opening whenever one opens a particular tab in Google Chrome.
Would not recommend ever having a GET perform an action on the BE.

In rails app who respond according to the http request?

Well, so far in each article I see people say server respond accordingly to the request type. If it is xml request then response is in xml and if it is ajax or html then response is in ajax or html. Browser send the request and server respond accordingly. My question is in rails app in which part this decision is taken? That is by server which part of the rails app we indicate?
This decision is taken inside the controller of the rails MVC framework and can be modified by the user. The user may wish not to respond to a particular type of request.
The distinction is made by suffix in URI, eg. ..../users/123.json. And You do it by yourself in controller.

How to prevent cross site scripting in MVC when AJAX request is sent by another website

I have an HTML form in MVC ASP.NET which the user fills out and the request goes to the server [AJAX] then we send a mail them to inform them. I use the hidden key to store information on the page.
I find that someone changed the key and then clicked then it's a problem that the mail go to other who are unknown for this case.
How can I be sure that nobody changes the hidden key and request is valid. The thing I want to do that HTML. antioforeignkey who is suitable for that.
But how can I implement antiforeignkey when I send AJAX request to server.
Are there any tricks to solve this problem in MVC?
Check out this link: http://blog.stevensanderson.com/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/
This link will help with AntiForgeryToken and Ajax calls: http://blogs.us.sogeti.com/swilliams/2009/05/14/mvc-ndash-using-antiforgerytoken-over-ajax/
Be sure to add #Html.AntiForgeryToken() to your form then you can use jQuery to pull that value. With the value you can then add it to the data attribute of your jQuery Ajax call.
var token = $('input[name=__RequestVerificationToken]').val();

Firebug and post request

I have to make some automatic work with site. There is a form and I have to get post-request it makes. The problem is that firebug cleans information about request due to redirect to another page, so I haven't time to save post data information. Are there any ways to "freeze" it?
You can press the persist button.

Ruby on Rails POST parameters on redirect_to

I have to make a call to a different url in one of my controllers on my site. The problem is that with all the parameters the other site requires I'm overflowing the url. Is there anyway to call another url from the controller and send all of the parameters using a POST?
I'm not expecting a response from the other site. Also, I think there's a way to do this using the Net::HTTP library thought I'm not sure how.
Thanks
You can't do a redirect and send POST data at the same time in the HTTP spec. Redirects are implemented by sending a simple Location: otherlocation.html header. POST data doesn't fit anywhere into that system.
Do you want the user to go to this page, or do you want to just send the data to the application yourself? If you want to send the data and not send the user there, use Ruby's Net::HTTP module. If you want to send the user, you may be forced to output a view with a form, and submit it automatically with Javascript. (Don't forget to degrade gracefully by offering a submit button in noscript tags.)
This is from the ruby docs:
require 'net/http'
require 'uri'
result = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
{'q'=>'ruby', 'max'=>'50'})
As you can see, you pass the params in as a convenient hash, unlike other languages that make you mess with http formatting.
You can also use the flash to transfer the information.
http://guides.rubyonrails.org/action_controller_overview.html#the-flash

Resources