wood burning stoves 2.0*
The moose likes JSP and the fly likes Capturing form element in the scriptlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Capturing form element in the scriptlet" Watch "Capturing form element in the scriptlet" New topic
Author

Capturing form element in the scriptlet

prithvi s zankat
Greenhorn

Joined: Jul 18, 2005
Posts: 12
Hi,
I want to access the HTML form element in the scriptlet(<% %> in the same page. Is it possible? if yes then please tell me how.

look at the example below.
helloworld.jsp is my jsp file.
--------------------------------------------------------------------------
<html>
<head>
<%!String javaString;
%>
</head>
<body>
<form name = "xyz" action="xyz.xyz">
<input type = text name = "abc" value="HelloWorld" />
<!--/////////////////////////////////////-->
<% i want to assign above declared javaString variable the value of text box, ie. javaString = 'the value of text box'.
%>
<!--/////////////////////////////////////-->
</body>
</html>
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
No way.
HTML is on the client-side, whereas scriplet code runs on the server-side.

Use javascript, instead.
[ September 30, 2005: Message edited by: Adeel Ansari ]
Gareth Faulkner
Greenhorn

Joined: Oct 29, 2004
Posts: 22
The scriptlet code will run on the server when the page is being called, so at that point in time, the user will not have had chance to enter any details.

Either use JavaScript or you will need the form to call a Servlet or another JSP page in order to extract the variables from form into Java variables.

Gareth
 
 
subject: Capturing form element in the scriptlet
 
Similar Threads
error in Textbox
HTML forms
Display value of cookie into text box
getting the value of the select list
Help required