Passing a java property to a javascript variable

Passing a java property to a javascript variable

i want to assign a java property to a js variable:

action class: collegename have a property in action class which having its getter/setter method.

JSP code: <%@ taglib prefix="s" uri="/struts-tags"%> <% response.setContentType("application/javascript"); %> var collegename = '';

Java Script code: alert("collegename"+collegename) it show on IE: 'collegename' is undefined it show on IE: 'collegename' is undefined

i have also tried this method: Action class: HttpServletRequest request; request =ServletActionContext.getRequest(); request.setAttribute("collegename ", collegename );

JSP code: <%@ taglib prefix="s" uri="/struts-tags"%> <% response.setContentType("application/javascript"); %> var collegename= '<%=request.getAttribute("collegename")%>';

Java Script code: alert("collegename"+collegename) it show on IE: 'collegename' is undefined

please suggest.

View Answers

March 1, 2011 at 1:21 PM









Related Tutorials/Questions & Answers:
Passing a java property to a javascript variable
Passing a java property to a javascript variable  i want to assign a java property to a js variable: action class: collegename have a property.../javascript"); %> var collegename = ''; Java Script code: alert("collegename
Passing variable
Passing variable  How to pass variable to HTTP object in HTMl or PHP
Advertisements
add a property to instance variable
add a property to instance variable  How to add a property to instance variable in iPhone SDK
convert javascript var to java variable - JSP-Servlet
convert javascript var to java variable  hi how to conver javascript var to java variable?  Hi Friend, We are providing you two ways: 1)a.jsp: function call(){ var name = "roseindia
passing value from javascript popup
passing value from javascript popup  How to take user input and pass that input value using popup in Javascript
property in javascript get set
property in javascript get set  How to create the get and set property in JavaScript?   Creating Get and Set properties in JavaScript... get(val) { this.nval = val; } } Tutorial : JavaScript getAttribute method
how to assign javascript variable value to a jsp variable
how to assign javascript variable value to a jsp variable  how to assign javascript variable value to a jsp variable
JavaScript display variable in alert
JavaScript display variable in alert  How to display variable in alert box? I am using javascript.   <html> <head> <script type="text/javascript"> function showAlert() { var name = "Roseindia
javascript variable value insertion in DB
javascript variable value insertion in DB  how can I insert javascript variable value into database using php
JSP Variable in Javascript
JSP Variable in Javascript          JSP Variable in Javascript helps you to pass jsp variable to javascript. The JavaScript include a function
How to Assign struts2 property to jsp variable
to assign to jsp variable   wants to assign <s:property...How to Assign struts2 property to jsp variable  In Struts2 <s:property value='count'/> I wants to assign <% int count = %><s
php variable in javascript
php variable in javascript  Access php variables in Javascipt or Jquery rather than php echo $variable
passing values form javascript - JSP-Interview Questions
passing values form javascript  please i want to pass values from javascript function to jsp code how can i do
JavaScript array passing
JavaScript array passing     ... Full example code of JavaScript array passing example is as follows: javascript...;   JavaScript array passing example </title> <script type="text
How to pass javascript variable in Scriplet of JSP?
How to pass javascript variable in Scriplet of JSP?  How can I assign the value of a javascript variable to a variable declared in jsp scriplet? Is it possible
passing value from javascript to jsp - JSP-Servlet
passing value from javascript to jsp  Hi... Is there any way to get the value from the javascript and print it on the current jsp page or print an array onto the current jsp page using javascript  Hi Friend, We
How to Assign struts2 property to jsp variable
How to Assign struts2 property to jsp variable  In Struts2 <s:property value='count'/> I wants to assign <% int count = %><s:property value='count'/><% ; %> But its not working.   Please
calling a javascript function by passing multiple values from applet in web application
calling a javascript function by passing multiple values from applet in web application  Hi all, I have a requirement like this, I have to call a javascript function from JApplet by passing 3 values. I am new to Applets
Java variable
Java variable   To what value is a variable of the String type automatically initialized
Converting jsp variable to java variable
Converting jsp variable to java variable  Hi how to convert java script variable to java variable on same jsp page
Getting Json data from servlet to javascript variable
Getting Json data from servlet to javascript variable  How do i get json data from my servlet on to a variable in javascript n bind the data to display onto sigma grid.Has anyone Idea how to do
Java parameter passing
Java parameter passing  What type of parameter passing does Java support
Passing Arguments. - Java Beginners
Passing Arguments.  Hi, im new in doing this passing arguments... and set the local version of the integer variable. Write a main method that shows that whilst the array is zeroed the integer variable is unchanged
Reference passing in java
Reference passing in java  plz tell me wat d meaning of refernce in java? for example : Class M(){ N n; } Class N(){ } wats dis meaning
Java argument passing
Java argument passing  How many ways can an argument be passed to a subroutine and explain them
how to call the array variable in scriptlet from javascript function
how to call the array variable in scriptlet from javascript function  This is the scriptlet code:- <% String[] abc={"saab","volvo","bmw","Benz","Porsche","Jaguar"}; %> Actually i want the array variable one by one
What is instance variable in Java?
What is instance variable in Java?  Hi, What is instance variable in Java? What is the use of instance variable? Thanks   Hi, In Java programming classes are used as base of Object oriented programming. Any variable
XML clonning with java and passing arguments
XML clonning with java and passing arguments  Hi, I have a XML file as follows. My requirements are as below. 1. Clone the whole xml file. 2. Iterate depending on the number provided. Say 1 means only one set with arugments1
Java Final Variable
Java Final Variable  I have some confusion --Final variable has single copy for each object so can we access final variable through class name,or it is necessary to create object for accessing final variable
unable to get value returned from javascript variable in page
unable to get value returned from javascript variable in page  Hi, I... and store it in a variable so that i can use it in my servlet to validate an if else... the value of the radio button from fisrt page to be stored in a variable so
Store Variable in Java
Store Variable in Java  How to store Variables in Java?   public class DoubleTest { public static void main(String[] args) { double...(aDouble); // Outputs 7.21 } }   Variable in Java
passing textbox value from one page to another page using html n javascript
passing textbox value from one page to another page using html n... of variable at onclick event of button and also want to print it in textbox...)page2.html: <html> <script LANGUAGE="JavaScript"> function getParams
array variable in a java program
array variable in a java program  How do i write a program that will prompt the user for a list of 5 prices, that cosist of the sum of all the prices, the average of the prices, and all prices that are higher than the calculated
Instance variable in java
Instance variable in java In this section you will learn about Instance variable in java. In java all variable must be declared before they are used... kind of variable in java, they are as follows : Local variable Instance
javascript query
javascript query  how to get javascript variable value into java variable?? i have one value in javascript variable(var name = value ) i want this name variable value in java variable (string name1
How to define a constant variable in Java?
How to define a constant variable in Java?   Hi, How to define a constant variable in Java? thanks   HI, The Constants variables... once its declared. For more related to constant variable in java Thanks
Applet - Passing Parameter in Java Applet
Applet - Passing Parameter in Java Applet   ...;HEAD> <TITLE>Passing Parameter in Java Applet</TITLE>...;message" value="Welcome in Passing parameter in java applet
Referance variable - Java Interview Questions
Referance variable  by using which reference variable we declare instance variable as local variable in java   Hi friend,Local variables... variable and parameter. When the method is called, the parameter slots are initialized
Static variable in java
Static variable in java. Static is a keyword in java used to create static methods, variable inside a class and static class. Static variable is also called class variable which belongs to class not to object. Static
java Transient variable - Java Beginners
java Transient variable  Hi, What is the use of transient variables in java?  Hi friend, The transient is a keyword defined in the java programming language. Keywords are basically reserved words which have
passing parameter from Java code to CSS file - Design concepts & design patterns
passing parameter from Java code to CSS file  hi, i have to pass a string variable from by java code to a CSS file so that i can use that variable in my CSS file. Plz help me as soon as possible
Java struts variable valu - Struts
Java struts variable valu  Hii.. can u suggest me how to declare a variable in my jsp page and then fetching its value in the action class.. my requirement is to execute a block of code depending on the value of the variable
Version of com.thetransactioncompany>java-property-utils dependency
List of Version of com.thetransactioncompany>java-property-utils dependency
JSP:Passing query as parameter - Java Beginners
JSP:Passing query as parameter  Hi Friends, I have a real tough..."; String qry3="select age from table13"; string q=Insert into emp values(?,?,?); int update=prep.executeUpdate(q); prep.setString(1,qry1); prep.setString
JSP:Passing query as parameter - Java Beginners
JSP:Passing query as parameter  Hi Friends, I have a real tough..."; String qry3="select age from table13"; string q=Insert into emp values(?,?,?); int update=prep.executeUpdate(q); prep.setString(1,qry1); prep.setString
Getting environment variable value from java
Getting environment variable value from java  Getting environment variable value from java
Java Property File
Java Property File This section contains the detail about property file, it's use and how can we read it via our Java code.   What is property... using Java Code You can read the key-value pair string of property file using Java
JavaScript Array Constructor
property in JavaScript. The constructor property of JavaScript returns a reference... JavaScript Array Constructor   ... the array.constructor property which returns the function name. Here is the code:ADS_TO_REPLACE_1
Using a variable filename - Java Beginners
Using a variable filename  Dear sir, my program a JFrame containes of 3 JTextFields and 2 different JButtons intend to sends data to 2 Input files... the buttons global variable and using the code e.getSource()== or by associating
Java Transient Variable
Java Transient Variables Before knowing the transient variable you should firs know about the Serialization in java. Serialization means making a object... mark that object as persistent. You can also say that the transient variable

Ads