tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid...@pidster.com>
Subject Re: Hidden form fields not found in request
Date Fri, 26 Oct 2007 08:35:23 GMT
Ognjen Blagojevic wrote:
> Hi Ashok,
> 
> Ashok Venkat wrote:
>> In the below code, i am submitting a form to itself  in the onload
>> method and changing some hidden form field values. After the form is
>> submitted, the hidden values are not available in the request
>> object.As a result, the page gets into an endless loop. 
> 
> Interesting. I treied it, and Firefox stops on JavaScript error in line
> 
>   this_form.BrowserType.value = navigator.appName;
> 
> so the form never gets submitted. After adding one more hidden field:
> 
>   <input type='hidden' name='BrowserType' value='unknown!'>
> 
> everything works fine.
> 
> 
> Regards,
> Ognjen

It looks like a nasty and somewhat unsafe solution to some problem or
other.  Is there a reason you need to submit the page at all?

If you're submitting the page to itself, AND using javascript, why not
just use the scripting to alter the contents of the hidden fields?

They can be uniquely identified on the page if you supply an id
attribute - you could modify them directly...


Alternatively, if you're just testing a concept at this stage, I'd
suggest that you could use an AJAX call to submit the page dimensions to
a backend during onloads execution.


p



>> Thanks for any help
>>
>> Code:
>> //test.jsp
>>
>> if(request.getParameter( "ScreenResolutionHeight" ) == null )
>> {
>> %>
>> <html>
>> <head>
>> <title>Please wait one moment...</title>
>> </head>
>> <body onload='SubmitOnLoad();'>
>>
>> <form method='post' id='ScreenResolutionForm'>
>> <input type='hidden' name='ScreenResolutionWidth' value='1024'>
>> <input type='hidden' name='ScreenResolutionHeight' value='768'>
>>
>> <script>
>> function SubmitOnLoad()
>> {
>> var this_form = FindElementById( 'ScreenResolutionForm' );
>> this_form.ScreenResolutionWidth.value = window.screen.availWidth;
>> this_form.ScreenResolutionHeight.value = window.screen.availHeight;
>> this_form.BrowserType.value = navigator.appName;
>>
>>
>> this_form.submit();
>> }
>>
>> function FindElementById( id )
>> {
>> if( document.getElementById )
>> {
>> return document.getElementById( id );
>> }
>> else if (document.layers)
>> {
>> return document.layers[id];
>> }
>> else if (document.all)
>> {
>> return document.all[id];
>> }
>>
>> return undefined;
>> }
>> </script>
>>
>> </body>
>> </html>
>> <%
>> }else {
>> ............
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message