0

Hi,

Can any one tell me how to pass a value from jsp to javascript both being different files.. ie a.jsp , b.js.. I have a hidden value in jsp i want to get its value in the javascript file.
thank you,
kaleeswaran

4
Contributors
3
Replies
7
Views
10 Years
Discussion Span
Last Post by shivnal
0

you can just call a javascript function from your jsp page. This will not be possible with Java objects though (to my understanding).

0

getting a value from jsp to js.. hmm sounds interesting. It's one of the most fundamental problem encountered by developers..

First of all your different js file should be included in the jsp..
like

<script language="JavaScript" src="../../js/imaster_code.js"></script></td>

then in the js file you may have a function which may look like

function openMethod(target,countSel) {
        
        document.forms[0].selectedNumber.value = countSelected;

/* do something here with the value */
}

in your jsp keep the accessed variable like

<html:hidden property="selectedNumber"/>

this will to a great extent solve your problem

0

Only set that value in Header using response.setHeader() in jsp and get it using req.getResponseHeader() in ajax

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.