Issue when submitting a big form - forms

EDIT:
It looks like I've made a lot of mistakes.
First, it seems that the problem didn't occur only in IE ( I must have failed during my tests)
Secondly, putting maxPostSize = -1 solved the problem. I changed both server.xml (the one on the apache-tomcat folder and the one pointing to the server's config of the server created via Eclipse)
Sorry again with my bad explanations. Thanks again for helping me.
I have an issue when trying to submit a form which contains an input with a big value (~1M characters).
<form id="whatever" method="post" action="'+url+'" accept-charset="utf-8" enctype="application/x-www-form-urlencoded"' + this.target + '>
<input type="hidden" name="whatever2" id="whatever2" />
</form>
document.getElementById(whatever).submit();
req.getParameter("whatever2");
When trying to obtain the parameter's value (whatever2) on server's side (doPost), it returns null when it is big (over 1 million characters) but works well when it contains less characters.
There is no problem when assigning the value but it seems that this one is not sent (no JS error)
This issue only appears on IE (using Quirks Mode), no problem using Mozilla Firefox.
Configuration:
Client : JavaScript
Server : Apache Tomcat / Java
Thus, is there some special limit even though I am using POST? Is there some parameter to change on the server or some JavaScript line to add to avoid this? Tell me if I forgot to mention some information.
Edit: The issue doesn't appear

Related

Issue finding elements on Barclaycard Samrt Pay hosted payment page using Selenium via Perl

I am trying to create a Selenium test script, in Perl (using Selenium::Remote::Driver) to test the checkout process of my application. I have recorded it with the Selenium IDE, and exported it with the Perl webdriver format plugin. The bits on my site work fine, but when I come to the Barclaycard HPP, it cannot find the elements. I have tried all applicable variations of find_element and find_element_by... and it does not work.
$driver->find_element_by_id("card.cardNumber")->clear;
$driver->find_element_by_name("card.cardNumber")->clear;
$driver->find_element_by_xpath('//input[#id="card.cardNumber"]');
$driver->find_element_by_xpath('//*[#onkeypress="return blockNonNumberEvents(event)"]');
The only difference I can see, is that the ID adn name tags both contain dots (i.e. id=card.cardnumber)
<input type="text" class="inputField" id="card.cardNumber" onkeypress="return blockNonNumberEvents(event)" onkeyup="card_validateCcNumber(event, 'card', card_types, card_logos, card_subVariantExtras, card_subVariantExtrasPhrase)" onchange="card_validateCcNumber(event, 'card', card_types, card_logos, card_subVariantExtras, card_subVariantExtrasPhrase) ; card_doCCCheck('card')" name="card.cardNumber" value="" size="24" maxlength="23">
I have verified that the tag values for ID and NAME are unique on the page, tried searching by xpath for the other tags. The only difference I can see is the dot in the NAME and ID fields.
I know this is a very specific issue, but I am hoping someone else has hit it too, and found a fix/fudge!
This could be due to the enclosing of card.cardNumber in quotes. When you do this, you are telling perl to concatate card and cardNumber so you end up with cardcardNumber.
If, on the other hand, you use single quotes as in: 'card.cardNumber' perl will take what is in between the single quotes literally. Thus giving you the desired ending string "card.cardNumber".

Mezzanine/TinyMCE filtering script type

I'm building a website using brython and I came by a problem that has nothign to do with it.
My problem is with Mezzanine or TinyMCE editor (I'm not sure which). To make brython work I need the script tag to be "text/python". But the editor filters it automatically to "text/javascript".
I disabled the filtering already, both in the admin panel and in the actual source code, I tried adding "text/python" to the RICHTEXT_ALLOWED defaults in the mezzanine configuration too.
Just to be clear, security is not an issue, this particular feature won't go online in the final version of the website.
Although the HTML specification does allow one to put any value other than "text/javascript" in script's type attribute, few projects do that, and Brython is one of those few. It is likely the "text/javascript" value is simply hardcoded in the editor and it won't allow you to change that.
(There is probably a big chance of having an issue closed as "won't fix/not a bug" or equivalent if you try to report this to the editor's issue tracker).
I think the workaround in this case is to write some javascript to change the text on the attribute on the relevant script tags to "text/python" prior to calling Brython. i.e., instead of triggering Brython on your page with
<body onload="brython()" >
Do something along
<body onload="function (){var x = document.getElementsByName("python"); for(var i=0; i < x.length; x++){x.type="text/python"};brython()}()" >
(and of course, add the attribute name='python' to all your python script tags)

Passing form value in joomla

I would like to upgrade one of my joomla 2.5 plugin (self-developed). It is a complex task, but here is this specific issue I couldn't solve. I would like to put an input field with a submit button at my articles (done), and after submitting I want to get it. So simple.
Here is the outline of the code:
The form:
<form action="" method="post">
<input type="text" name="info">
<input type="submit" value="ok">
</form>
The process:
$jinput = JFactory::getApplication()->input;
$foo = $jinput->get('info', '444');
print_r($foo);
Basically it should work, but somehow I don't get the value, always recive the default value '444'. If I change the action to an external php file, and process in php-way, it works.
What I checked so far:
a. change form method to GET. Result: the needed value appears properly in the article's URL, but still print the default value '444' not the value I see in the URL (if the default value isn't set, it doesn't print anything).
b. pass the value to an external .php file, store in session, and echo the session value in the article, but empty again.
Maybe I will force to get the GET values by exploding the $_SERVER["REQUEST_URI"], but I can't sleep until I find out what could be wrong with desired process.
Anyone can help?
UPDATE: maybe important - I use K2 plugin.
So far I could figure out the following:
it is a special case. On my local server the code works fine both with normal joomla articles and K2 component articles.
on my website the code also works fine with normal joomla articles, so it is defenietly a K2 settigns-issue.
there was a chance the problem is related to K2 advanced SEF settings (specifies the url of the K2 item), but it isn't. The problem is on my website, so I used on my localhost-version the SEF settings of the website-version, and I recived the values fine. == not K2 advanced SEF settings problem.
This is the answer for my question: "should find which K2 setting is causing the problem"
UPDATE. Solution: turn off caching at global configuration, so the page isn't loading from cache. In cache are no given values stored - obbbbbviously.

Adding <h:form> causes java.lang.IllegalStateException: Cannot create a session after the response has been committed

I'm facing the following exception in a very simple JSF 2 page after adding <h:form>:
java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2758)
at org.apache.catalina.connector.Request.getSession(Request.java:2268)
I'm using Mojarra 2.1.3 and PrimeFaces3.0M4, on Tomcat 7.0.22 and JDK 7.
The page is a very basic data table:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<p:dataTable var="car" value="#{tableBean.cars}">
......
</p:dataTable>
</h:form>
</h:body>
</html>
The page shows correctly on the browser, but on the console I see the exception. The Exception does disappear if I remove the <h:form>.
How is this caused and how can I solve it?
This is a known problem and has been reported by yours truly as issue 2215. This will occur when the response buffer has overflowed (due to large content) and the response is been committed before the session is been created. This is result of bit overzealous attempts of Mojarra to postpone "unnecessary" session creation as much as possible (which is at its own a Good Thing though).
Until they get it fixed, there are several workarounds:
Create a Filter which does HttpServletRequest#getSession() before FilterChain#doFilter(). Advantage: no need to change JSF configuration/code. Disadvantage: when you want to avoid unnecessary session creation yourself as well.
Call ExternalContext#getSession() with true in bean's (post)constructor or preRenderView listener. Advantage: actually, nothing. Disadvantage: too hacky.
Add a context parameter with name of com.sun.faces.writeStateAtFormEnd and value of false to web.xml. Advantage: unnecessary session creation will be really avoided as opposed to #1 and #2. Disadvantage: response will now be fully buffered in memory until </h:form> is reached. If your forms are not extremely large, the impact should however be minimal. It would however still fail if your <h:form> starts relatively late in the view. This may be combined with #4.
Add a context parameter with name of javax.faces.FACELETS_BUFFER_SIZE and a value of the Facelets response buffer size in bytes (e.g. 65535 for 64KB) so that the entire HTML output or at least the <h:form> (see #3) fits in the response buffer. Advantage/disadvantage, see #3.
Add a context parameter with name of javax.faces.STATE_SAVING_METHOD and value of client to web.xml. Advantage: session will not be created at all unless you have session scoped beans. It also immediately solves potential ViewExpiredException cases. Disadvantage: increased network bandwidth usage. If you're using partial state saving, then the impact should however be minimal.
As to why the problem disappears when you remove <h:form>, this is because no session needs to be created in order to store the view state.
Update: this has as per the duplicate issue 2277 been fixed since Mojarra 2.1.8. So, you can also just upgrade to at least that version.
With the new version 2.1.21 released yesterday of javax.faces this problem seems to have disappeared.
Declare the new version:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.21</version>
</dependency>
and replace the javax.faces.jar in the glassfish modules folder replacing the javax.faces.jar for the new version 2.1.21.
In my case (myfaces-2.2.8 & Tomcat 8.0.23) the Problem was a typo in the welcome-file of web.xml.
While debugging i saw, that Tomcat created as expected a 404, but somehow myfaces tried to access afterwards the Session, which caused then a java.lang.IllegalStateException: Cannot create a session after the response has been committed.
Using a valid page in welcome-file of web.xml fixed the Problem for me.
You may need to add an <f:view> and </f:view> before and after h:form elements, plus add the link to you html tag for jsf tags
<html xmlns:f="http://java.sun.com/jsf/core">
for this to work.
If you are using Spring MVC and call is made by Spring Forms then we should use GET method instead of POST(to fetch data) and there should be no input field we can use intead.

Intermitent problem with Struts 1.2.8 HTML taglib and JBoss

I have a legacy Struts 1.2.8 application that I'm maintaining and porting from Oracle Application Server (OAS) 10g to JBoss 4.2.3. I have a JSP that uses the Struts HTML tag library. The JSP page is backed by EJBs. The user enters an item number and the page displays the details of the item (e.g. item from a product catalog).
On the first 3 times I use this page, the item details are returned correctly. But for some reason, on the fourth submission of the page and on subsequent submissions, some of the item information is missing. I'm using
<html:hidden property="itemNumber"/>
<html:text property="itemNumber"/>
tags. The bizarre part of this problem is that I can't recreate the problem in OAS. In addition, if I replace the above html:text tag with
<input type="text" value="<%=itemForm.getItemNumber() %>" >
The code works correctly. My guess is that this is a session/request/scope problem. But I haven't found the correct configuration.
Is there special configuration required for Struts in JBoss?
Check the scope being used for the action in the struts-config.xml file. Most likely you probably want the scope to be request.
The problem was caching in the Jasper JSP engine. The default configuration is
enablePooling - Determines whether tag handler pooling is enabled. true or false,
default true.
I was able to set enablePooling to false and my problem was resolved. I assume this is a bug in Jasper. This bug appeared when a JSP custom tag (e.g. html:hidden) is followed by a jsp:attribute where the name is "value". See below.
<html:hidden property="itemNumber"/>
.
.
<html:text property="regularPrice" maxlength="9" readonly="<%=disabled%>"
tabindex="9" onkeyup="onRegularPriceChanged(this)">
<jsp:attribute name="value">
<webmodules:currency onlyDisplayValue="false">
<jsp:attribute name="currencyValue">
<bean:write name="updateItemForm" property="regularPrice"/>
</jsp:attribute>
</webmodules:currency>
</jsp:attribute>
</html:text>
There seems to be a namespace and caching conflict between the "value" that is set by the html:hidden and the "value" that is set by the jsp:attribute. After the JSP page was used twice the cached value set by the jsp:attribute was being used as the value for html:hidden.