tags:

views:

455

answers:

2

I want to pass parameter from a Javascript function to another JSP page. Currently I am doing like this:

function viewapplet(strPerfMonPoint) {
    var dateSelected = document.forms[0].hdnDateSelected.value;
    document.forms[0].hdnPerfMonPoint.value = strPerfMonPoint;
    var win;   
    win = window.open("jsp/PopUp.jsp?GraphPerfMon="+strPerfMonPoint+"&strDateSelected="+dateSelected, strPerfMonPoint,"width=800,height=625,top=40,left=60 resizable=No");     
}

I added hdnPerfMonPoint hidden variable and tried to acces in PopUp.jsp using request.getparameter(hdnPerfMonPoint) but it is giving null.

I want my window.open like:

window.open("jsp/PopUp.jsp", strPerfMonPoint,"width=800,height=625,top=40,left=60 resizable=No");   

Please suggest solution.

+1  A: 

Are you quoting it properly? (and note the name change!)

String GraphPerfMon = request.getParameter("GraphPerfMon");

"The returned value of a parameter is a string. If the requested parameter does not exist, then a null value is returned."

scunliffe
Thanks for ur quick response ...Actually i want this parameter in my scriplets... not in javascript... yeah i am getting GraphPerfMon and strDateSelected using request.getparameter() method..I want that my url doesnot show values of GraphPerfMon and strDateSelected
gautam
if you need it in the JSP, and can't pass it on the URL you have only a few options. e.g. you could set something in the session via AJAX... and retrieve it in the popup... or you could submit a form via post on your opener... with a target attribute set top your new window name (but you lose the ability to resize the popup/control any chrome features)
scunliffe
+1  A: 

You've actually passed it as GraphPerfMon as well. So request.getParameter("GraphPerfMon") should return the desired value. If you really insist in using the value of the hidden input element of the opener window instead for some reason, then you need Javascript.

var hdnPerfMonPoint = window.opener.document.forms[0].hdnPerfMonPoint.value;

To learn more about the wall between JSP and Javascript, you may find this article useful as well.

BalusC