Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Struts Passing a java property to a javascript variable
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Vijay
Passing a java property to a javascript variable
1 Answer(s)      3 years and 10 months ago
Posted in : Struts


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.


Advertisement
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
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 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
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 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
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
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
Java parameter passing
Java parameter passing  What type of parameter passing does Java support
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">
Java variable
Java variable   To what value is a variable of the String type automatically initialized
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
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
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
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
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
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 argument passing
Java argument passing  How many ways can an argument be passed to a subroutine and explain them
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
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 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 file... of property file using Java code as given below : The property file is given
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
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
 

 

 

DMCA.com