You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Cassius V. de Magalhaes" <cv...@terra.com.br> on 2005/05/23 23:56:30 UTC

How to change the value of a form's text field by scriplet?

Hello,

I would like to change the value of a form's text field by scriplet, is it possible, please?
Through Javascript, I can use the form name plus the name of the field, for example,
"myform.address.value='xxx'". I know I can do "myform.address.value='<%= something %>'", where "something" is a
scriplet variable declared previously. Is it possible to change the value of a form field inside of a scriplet
just as we can by a javascript code, please?

TIA,
Vinicius.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: How to change the value of a form's text field by scriplet?

Posted by Will Hartung <wi...@msoft.com>.
> From: "Cassius V. de Magalhaes" <cv...@terra.com.br>
> Sent: Monday, May 23, 2005 2:56 PM

> I would like to change the value of a form's text field by scriplet, is it
possible, please?
> Through Javascript, I can use the form name plus the name of the field,
for example,
> "myform.address.value='xxx'". I know I can do "myform.address.value='<%=
something %>'", > where "something" is a
> scriplet variable declared previously. Is it possible to change the value
of a form field inside of a > scriplet
> just as we can by a javascript code, please?

JSPs and the Servlet model do not expose HTML forms as some large, first
class object that you can change using something like
"myform.address='something'".

Typically you'd do something very basic like:

<form action="/url">
Name: <input type="text"> <%= something %></input>
</form>

There are, of course, innumerable frameworks and such that can present HTML
elements and forms to your Java code as objects (JSF for one), but the above
is the basic of basics on how it all works and is inevitably done.

Regards,

Will Hartung
(willh@msoft.com)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: How to change the value of a form's text field by scriplet?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I should also mention, you can certainly do something like this:

<script>
function changeIt() {
   myForm.myField.value = "<%=someValue%>";
}
</script>

...but that's not much different than just setting the value of the 
field with a scriplet.  However, if you perhaps have some discrete 
values that you want to be able to change the field to, like maybe 
something like a "previous value" button, and you have the value at the 
time the JSP is interpreted, you can do this and just call changeIt() in 
response to onClick() of the button.  That's something of a hybrid.

Frank

Frank W. Zammetti wrote:
> You might not be asking this, but...
> 
> Scriplets execute on the server, not on the client.  The results of a 
> scriplet are in essence "inserted" into the response.
> 
> So in that regard, no, you can't use a scriplet to change the value of a 
> text field as you would with Javascript because Javascript executes on 
> the client *AFTER* the response has been completely rendered and 
> returned to the broser, while a scriplet executes *WHILE* the response 
> is being rendered and *BEFORE* it is returned to the client.
> 
> Does that answer the question, or did I misinterpret?
> 
> Frank
> 
> Cassius V. de Magalhaes wrote:
> 
>> Hello,
>>
>> I would like to change the value of a form's text field by scriplet, 
>> is it possible, please?
>> Through Javascript, I can use the form name plus the name of the 
>> field, for example,
>> "myform.address.value='xxx'". I know I can do 
>> "myform.address.value='<%= something %>'", where "something" is a
>> scriplet variable declared previously. Is it possible to change the 
>> value of a form field inside of a scriplet
>> just as we can by a javascript code, please?
>>
>> TIA,
>> Vinicius.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>>
>>
>>
>> .
>>
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: How to change the value of a form's text field by scriplet?

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
You might not be asking this, but...

Scriplets execute on the server, not on the client.  The results of a 
scriplet are in essence "inserted" into the response.

So in that regard, no, you can't use a scriplet to change the value of a 
text field as you would with Javascript because Javascript executes on 
the client *AFTER* the response has been completely rendered and 
returned to the broser, while a scriplet executes *WHILE* the response 
is being rendered and *BEFORE* it is returned to the client.

Does that answer the question, or did I misinterpret?

Frank

Cassius V. de Magalhaes wrote:
> Hello,
> 
> I would like to change the value of a form's text field by scriplet, is it possible, please?
> Through Javascript, I can use the form name plus the name of the field, for example,
> "myform.address.value='xxx'". I know I can do "myform.address.value='<%= something %>'", where "something" is a
> scriplet variable declared previously. Is it possible to change the value of a form field inside of a scriplet
> just as we can by a javascript code, please?
> 
> TIA,
> Vinicius.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> 
> .
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org