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,

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

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..

<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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.