[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » JSP
 
RSS feed
 
New topic
Author

How can we put jsp or javascript code in java code on jsp

Ravinder Partap Tanwar
Greenhorn

Joined: Jun 21, 2009
Messages: 2

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

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

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

Please read The Secret Life of JSPs.

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » JSP
 
RSS feed
 
New topic
replay challenge