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

Ads









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
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
passing value from javascript popup
passing value from javascript popup  How to take user input and pass that input value using popup in Javascript
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
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
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
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
JavaScript array passing
JavaScript array passing     ... code of JavaScript array passing example is as follows: javascript_array... array passing example </title> <script type="text/javascript">
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
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
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
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
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
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
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
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
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... is one of the data type in java ,identifier is one of the name of the 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
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
Applet - Passing Parameter in Java Applet
Applet - Passing Parameter in Java Applet   ... case applet should display "Welcome in Passing parameter in java applet...;Passing Parameter in Java Applet</TITLE> </HEAD> <
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
Version of com.thetransactioncompany>java-property-utils dependency
List of Version of com.thetransactioncompany>java-property-utils dependency
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
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 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... string of property file using Java code as given below : The property file

Ads