Author
How can we put jsp or javascript code in java code on jsp
Ravinder Partap Tanwar
Greenhorn
Joined: Jun 21, 2009
Messages: 2
posted Jul 03, 2009 03:48:41
How can we pass the input of jsp page on the java code in the same jsp?
for e.g. I want to put value of Gender field from the jsp into the java Variable gender.
document.form[0].gender.value
<%
String gender = document.form[0].gender.value;
%>
Thanks and Regards
Ravinder Partap
- Ravinder Partap
David Newton
Author
Bartender
Joined: Sep 29, 2008
Messages: 6676
posted Jul 03, 2009 04:53:40
You don't: the Java has executed before it gets to the client.
Consultant/Trainer | Polyglottal Developer | Struts Committer/PMC | Struts 2 Web Application Development
Anand Ramadurg
Greenhorn
Joined: Aug 14, 2008
Messages: 1
posted Jul 03, 2009 05:16:02
Hi Ravinder,
Javascript will be executed at client side ( Browser) while scriplet ( i.e java code written in jsp ) will be executed at the server side. I don't know, what you are trying to achieve here.. May be you should explain your problem in detail...
Please go through this link... http://java.sun.com/products/jsp/html/jspbasics.fm.html
Bear Bibeault
Author and opinionated walrus
Sheriff
Joined: Jan 10, 2002
Messages: 36411
posted Jul 03, 2009 10:19:31
Please read The Secret Life of JSPs .
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]