Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 26th, 2005, 11:06 PM
Registered User
Join Date: Feb 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to assign javascript value to java?


we can assign java variable value to the javascript variable in HTML <head> tag the as follows:

<script language="JavaScript">
    var jsVar = '<%=javaVarVal%>'

Is there any way to assign javascript variable value to javavariable.

Old June 27th, 2005, 03:34 PM
Friend of Wrox
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts

To pass a value to JSP you need to submit it to the page when opening it, if that makes sense. You cannot write directly to the variable, remember javascript runs on the client, java runs on the server. You must submit a request to the server to pass the values, by opening a page.

What you can do is to use javascript to open the page, so your javascript creates a link with relevant parameters to pass to the server when the next page is opened, though this is not something I do, it doesnt really seem worth the hassle.

I use javascript for rollovers etc. and to check form fields prior to submission, but pass the actual parameters from links/forms.

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do you assign php to a row value in javascript RJ2001 Javascript How-To 0 August 13th, 2007 04:32 PM
How to assign xsl param with java script varaible Sanjay.Verma XSLT 1 November 21st, 2006 04:34 AM
assign javascript variable to asp variable manjunath_c_k Classic ASP Basics 1 September 14th, 2006 07:35 AM
How To Assign Value To Session Using Javascript janice.koay Classic ASP Professional 1 May 9th, 2006 12:59 AM
How to assign javascript to Java? salahu Pro JSP 1 August 8th, 2005 03:05 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.