Solved

Clientside variables with Java Server Pages

Posted on 2002-03-23
1
207 Views
Last Modified: 2010-04-01
Hello,
I am new to JSP, having been an ASP programmer, and have come across the following problem:

When I am writing clientside Javascript in an ASP page, and I want to refer to a serverside ASP variable, I use the following syntax: "<%=pCounter%>" (quotes are included in the code clientside but not serverside).

ie lstrurl = lstr1 & "<%=pCounter%>"  & lstr2

Is there a similar syntax in JSP??  I have a similar problem in that I want to refer to a serverside JSP variable in my clientside Javascript code, in a JSP page.  All help much appreciated!

Thanks,
Paul Trimming
0
Comment
Question by:Trimtrom
1 Comment
 
LVL 19

Accepted Solution

by:
cheekycj earned 50 total points
ID: 6892321
actually, what you have is exactly what it would look like in JSP too. :-)

<script>
var lstrurl = lstrul + "<%=JSPVariable%>"
</script>

appends JSPVariable to the ClientSide JavaScript Variable lstrurl.

To learn more about JSPs check out:
http://www.jsptut.com/
http://www.jspin.com/home/tutorials
http://www.1001tutorials.com/java/jsp/index.shtml

HTH,
CJ
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse problems view not showing all the time 4 88
java cyclic graphs 15 212
console vs log file 16 83
thymeleaf natural templating vs JSP 2 139
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Building a successful professional career is a long and difficult journey, especially in case if your decisions are not chosen carefully. For example, if you think that you can get to the desired position without experience and apply for it, your ch…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question