Computing.Net > Forums > Programming > jsp variable in java script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

jsp variable in java script

Reply to Message Icon

Name: mythri
Date: May 5, 2004 at 04:35:06 Pacific
OS: windows xp
CPU/Ram: p 3 128 ram
Comment:

Hi,
iam trying to use the variable declared in jsp tags in the scipt.
both exists in the same jsp page.
I need to access the jsp variable in script function,where that jsp variable contain the data accessed from the database.
its urgent plz

kowsalya



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: May 5, 2004 at 06:00:14 Pacific
Reply:

Use the = jsp tag to display the value of the jsp variable and make it part of the javascript code. Replace the brackets below with < and >.

My JSP book is not handy, but it should look something like this:


var name;
name="[%= jspName ]";


0

Response Number 2
Name: gpp
Date: May 5, 2004 at 15:18:56 Pacific
Reply:

Dont forget the % sign on the closing bracket as well..


0

Response Number 3
Name: mythri
Date: May 5, 2004 at 22:10:16 Pacific
Reply:

Hi,
I tried with 2 stmts wt u mentioned above but it is not working.
nothing is being displayed on the browser.but in the status bar it is giving like "done with some errors on the page"

iam giving the code .


<%String name="something";%>
<script>
window.alert("hello");
var x="<%=name%>";
window.alert("hai"+x);
</script>


iam able to get the first alert box
but not the second alert box.

IT IS URGENT HELP PLZ..

kowsalya


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: jsp variable in java script

reseting variable in java www.computing.net/answers/programming/reseting-variable-in-java/334.html

AWK in bash script www.computing.net/answers/programming/awk-in-bash-script/14878.html

urgent help in jsp www.computing.net/answers/programming/urgent-help-in-jsp/10401.html