Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting jsp value in javascript file

Tags:

javascript

jsp

I have the following code in abc.jsp:

<%@page import="soundcap.Soundcap"%>

<%

    Soundcap cfl = new Soundcap();
    var sfl = cfl.playFile();

%>

I need the value of sfl in an external javascript file (jcode.js). How can I get this value (sfl) from jsp in javascript?

like image 729
bdfios Avatar asked Apr 22 '13 19:04

bdfios


1 Answers

use this...

<%
//get your sfl
 %>
  <input type="hidden" id="sfl" value="<%=sfl%>">

in your js file use

var sfl=document.getElementById("sfl").value; 
like image 111
rahul maindargi Avatar answered Oct 08 '22 07:10

rahul maindargi