-
1. Re: FileUpload generates large Request Header with Request Parameters
michpetrov Jan 21, 2015 4:33 AM (in response to horowitzathome)1 of 1 people found this helpfulHi,
you can put the fileupload in a separate form, having one big form for everything may not be ideal. But I don't think I understand the issue, the only things affected are the request URL (which would contain all the input values) and request payload that contains the file that you're uploading and I'd expect that to be bigger than everything else. I don't see anything in request headers that would be affected by the contents of the form.
-
2. Re: FileUpload generates large Request Header with Request Parameters
horowitzathome Jan 21, 2015 6:25 AM (in response to michpetrov)Yes, I think that’s the point, the request URL gets very large because it contains all the parameters. I am wondering why the fileUpload is doing that resp. why the parameters are necessary in this case. For lets say a commandButton the parameters are not part of the request URL.
Anyways, what I have done already is what you also suggested, to split the input controls in several forms.
-
3. Re: FileUpload generates large Request Header with Request Parameters
michpetrov Jan 21, 2015 10:09 AM (in response to horowitzathome)That's weird, the long URL is a result of jsf.getViewState() (in jsf.js), which returns all relevant input/value pairs (and that's part of JSF). But that method is called for every ajax request, so you should be seeing large URLs even with a4j:commandButton and any other ajax component.
-
4. Re: FileUpload generates large Request Header with Request Parameters
horowitzathome Jan 22, 2015 4:44 AM (in response to michpetrov)Okay, I have made the following small sample:
<h:body>
<f:view>
<rich:panel id="mainPanel">
<h:form id="form" acceptcharset="UTF-8">
<h:inputText id="i1" value="#{uploadBean.input1}" />
<h:inputText id="i2" value="#{uploadBean.input2}" />
<h:inputText id="i3" value="#{uploadBean.input3}" />
<a4j:commandButton id="cb1" action="#{uploadBean.action1}" value="rich" execute="i1" render="cb1"/>
<rich:fileUpload fileUploadListener="#{uploadBean.uploadListener}" id="uf1" maxFilesQuantity="1"
render="uf1" execute="i1" />
</h:form>
</rich:panel>
</f:view>
</h:body>
A click on the command button generates this URL:
http://localhost:8080/RichUploadWeb/faces/Upload1Main.xhtml
An upload generates this URL.
Is it really necessary to append all the request parameters when uploading files? The problem is, when having the uploadControl within a from which has many other input controls, the URL can get quite a lot of request parameters and this is exactly the problem we have in our system.
-
5. Re: FileUpload generates large Request Header with Request Parameters
michpetrov Jan 22, 2015 6:48 AM (in response to horowitzathome)I see. In the JSF ajax request the viewState is actually sent as the content of the request. As far as I can tell we had to put it in the URL because otherwise the request isn't processed correctly on servers that use Servlet 2.5. I'll take another look at it.
And yes it is necessary to append all the parameters. The execute attribute is used on server side, it does not filter the values that are being sent. So we have to send everything, and the server then decides which values to use.
-
6. Re: FileUpload generates large Request Header with Request Parameters
horowitzathome Jan 23, 2015 2:22 AM (in response to michpetrov)Hello,
the file upload is a POST request. What I know so far is, that POST requests must not transmit form data via the URL but rather via the request body.
In this case this POST request of the file upload transmits the form data via the URL, what in my opinion is not correct and makes terrible problems because usually you have the upload control embedded in a form with some other input controls which might contain large data. In my case I have some other input fields which can contain some KB of data. So when I now do the upload and the other input fields are filled with these data, I get from our web server an error that the URL exceeds the maximum allowed size (in our case about 12KB).
So wouldn’t it be more correct to post the form data via the request body rather than via the URL?