I have something like the below code. I need to pass the variable selectedIndex to the JSTL code. How can I do this?
function updateSP(selectedIndex)
{
<c:if test="${entry.key eq IC.oList[selectedIndex]}">
}
I have something like the below code. I need to pass the variable selectedIndex to the JSTL code. How can I do this?
function updateSP(selectedIndex)
{
<c:if test="${entry.key eq IC.oList[selectedIndex]}">
}
Share
edited Mar 29, 2010 at 12:23
BalusC
1.1m376 gold badges3.7k silver badges3.6k bronze badges
asked Mar 25, 2010 at 17:17
venkikamvenkikam
111 silver badge2 bronze badges
0
2 Answers
Reset to default 3First, you need the following concept right: Java/JSP runs at the server machine and produces a HTML/CSS/JS page. The server machine sends HTML/CSS/JS page over network (HTTP) to the client machine. Client machine retrieves HTML/CSS/JS and starts to interpret HTML to display a markup structure, apply CSS to style and position the structure and execute JS on the resulting the HTML/CSS.
There is no means of any line of Java/JSP code at the client machine. Rightclick page and view source. The only way to pass Java/JSP variables to Javascript is to just output them as if it's a Javascript variable so that it has instant access to it once it runs at the client machine. The only way to pass Javascript variables to Java/JSP is to just send a HTTP request with that variable as parameter and have Java/JSP to listen on that specific request.
More background information and code examples can be found in this article.
jstl is executed in server side so you can't pass a javascript variable to jstl. What you can do is generate dynamic javascript using jstl.
Please use the tool to format your code.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745073508a4609697.html
评论列表(0条)