gautam
gautam

Reputation: 1

pass parameter from javascript to another jsp

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.

Upvotes: 0

Views: 7518

Answers (2)

BalusC
BalusC

Reputation: 1109685

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.

Upvotes: 1

scunliffe
scunliffe

Reputation: 63676

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

Upvotes: 1

Related Questions