Accessing request parameters in Orbeon form via POST - orbeon

I want to access some request parameters in an Orbeon form sent via post to this form. I tried to use the XPath expression xxf:get-request-parameter('task_id') within the form, but this only works when the parameter is attached to the url (e.g. orbeon/fr/Activiti/dokumentfreigabe/new?task_id=4711).
Since I do not want to send all parameters in the url (but via POST and SSL), I need a solution to access request parameters in an orbeon form sent as a POST-Parameter.

You can't access parameters sent to the form with a form POST with an XPath function. Could you use an HTTP header to pass this value, instead of a form POST? If it possible, then you could use xxf:get-request-header('your-header').
If the form POST is done by the browser, and not by another server-side app or filter or reverse proxy, then you obviously wouldn't be able to set the header directly from the browser. However, you could continue doing the form POST from the browser, and add a servlet filter that extracts the value, and sets the value of a header, so you can then read it with xxf:get-request-header('your-header').

Related

Create a URL with credentials

I would like to provide links to a website with the credentials already within the link. The link is:
https://mychart.covh.org/MyChart/
The credentials are:
Username = AllStarUser
Password = FiveStarPassword
I have tried
https://mychart.covh.org/MyChart/?Username=AllstarUser,Password=FiveStarPassword
and
http://mychart.covh.org/Mychart/logincheck.asp?login=AllStarUser&password=FiveStarPassword
but these don’t work. Any suggestions?
This is a POST form (method="post"). The form data has to be enclosed in the body of the HTTP request.
If it were a GET form (method="get"), you could enclose the form data in the URL, which is specified in the header of the HTTP request.
See also:
HTML 4.1: Form submission
HTML 5.2: Form submission
Stack Overflow: How are parameters sent in an HTTP POST request?
If this was a "get" -
https://mychart.covh.org/MyChart/logincheck.asp?Login=AllStarUser&Password=FiveStarPassword
would be correct.

How to prevent form submission using GET method in JSF 2.0?

I am developing an JSF 2.0 application for IBM Webshere 7.0 and I want to prevent user submitting a form using the GET method for security reason i.e user will not be able to submit a form appending the form values to the Query String.
Is there any simple solution for this or I need to build filter to prevent this ?
When you use JSF <h:form> it does a POST request be default. Even though a Query string is sent, since the submission method is POST, the result is not sent as a query string, that is, it is not added to the action URL of the form. Rather, the string is sent as the body of the HTTP request and the doPost() method of the FacesServlet will be invoked.
See also:
Proper way to call servlet from Facelets?
http://en.wikipedia.org/wiki/Query_string

Rails take base64

In rails i need to take a base64 string, and use it to generate a picture in rails. Now i'm having trouble, because i need to interact with AJAX calls (im strictly working on the server side, another guy is doing that client work) to send pictures. So far i've been taking requests in my application by having data transferred through the url (in the AJAX requests) but now im not sure if it's possible to transfer such a huge string through the url. How could i take in the data (like how could he pass it to me) to generate a picture.
Note: i've been using paperclip for my application so far, but now uploading through the form is not an option, it needs to be in an AJAX call where data is passed in a single call.
You're right, most browsers limit the length of a URL. The limit on IE8/9 is 2083 characters. Even if your particular browser has a higher limit, many servers limit the URL length as well (apache's default limit is right around 8k). It would be best to submit the image as a POST request with the data in the POST body.
I would use jQuery to POST JSON data to the server. In the controller, if this is set up correctly, you won't have to do a thing to parse the JSON. ActiveSupport will recognize the content type and parse it out into the params hash automatically.
Actually posting the data will depend on which javascript library you're using. Here's an example in jQuery, which you'd probably want to wire up to the onclick event of a submit button. This assumes you have a named route called process_image. This code would go in your view.
$.post(<%= process_image_path %>, { b64_img: "your_base64_image_data" });
In your controller, you can access the posted data with params[:b64_img]. If you want to return something from the controller back to the client, you can do this in the controller:
render :json => #model_object
And change the jquery call to look like this so you can do something with the return value:
$.post(<%= process_image_path %>, { b64_img: "your_base64_image_data" },
function(data) {
// do something with the data returned by the controller
});
Hope this helps. You can read more about the jQuery post call I used here: http://api.jquery.com/jQuery.post/
Dan

Asp.Net MVC Form[GET]. Correct action url

I've got search form, which contains checkboxlist which is binded to my model. So when I set GET method to form I got long url:
(I even have exception:
The length of the query string for this request exceeds the configured maxQueryStringLength value.)
it's expecting, [0].IsSelected=false&[0].Id=6&[1].IsSelected=false...
But I would like url like this
www.domain.com/Action/Comma-separated-selected-idx
for example:
www.domain.com/Search/1,6,7
How can I fix,edit form get action? Thanks
I would do a POST instead, then redirect to the URL you desire.
OR
You could capture the form with some JavaScript and build the URL there.
agreed, POST or JS are your best options, I'd opt for a POST.

Posting a form from Rails programmatically

How would I go about creating and posting a form POST request from inside some Rails code?
The use case I have is that I have received a form request, and I would like to forward this request on to a third party with my parameters intact.
I should add that I want to redirect the user out to the third party with the form too.
From ruby docs for Net::HTTP:
res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
{'q'=>'ruby', 'max'=>'50'})
You could just pass params as the second arg, eg:
Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'), params)
redirect_to some_path
Also, don't forget to require the lib:
require 'net/http'
require 'uri'
You're going to have to do this via Javascript, as there is no way of redirecting a POST request (as per the HTTP/1.1 protocol).
You might be able to do it this way:
receive the post form the user
change whatever data you mean to
respond to the request with a form full of hidden fields
automatically post that form to the third party via javascript on dom-loaded
Alternatively:
set the form action to be the third party url
intercept the onsubmit event with js
change whatever data you need, either by simple client-side manipulation of the form
or, post an ajax request to your app to treat the data, and replace the fields you need with from the ajax response
with the data now massaged, let the form go through to the third party

Resources