Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Capturing form element in the scriptlet

 
prithvi s zankat
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic