Problem: URL rewriting through javascript

the following javascript function is called on drop down's onchange() method...

this is java script function .. which reloads the same page

function showDataByForm()

{

var selValue = document.CATEGORY.ddlViewByForm.value;

document.CATEGORY.ACTION ='ViewHeading4.jsp?CNT=0&TOTAL=0&formId=FRM-1';

alert(document.CATEGORY.ACTION);

document.CATEGORY.submit();

}

But when i retrieve the value in the jsp page.. it alwasys returns null

here is the code

formId = request.getParameter("formId");

when displayed .. formId is always equal to null...

what could be the reason?

[771 byte] By [ali_hammada] at [2007-11-27 8:32:49]
# 1
What are you getting if you get cnt,cnt = request.getParameter("CNT");if you get the full string, "0&TOTAL=0&formId=FRM-1",then get this way and extract whatever you want.
skp71a at 2007-7-12 20:28:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

The problem is since you are submitting the form and if it is a method type "GET" then it will do URL rewriting automatically by appending all the params (like input types text, hidden etc) in the form as query string.

If it is of method type POST, then it will not append but you can still access them because they are posted.

what ever action you are giving 'ViewHeading4.jsp?CNT=0&TOTAL=0&formId=FRM-1', once it is submitted you might not see the query string after displaying the ViewHeading4.jsp. It might be looking like ViewHeading4.jsp?

So either have hidden variables in your form for each param, say CNT, TOTAL and formId and set the values in your javascrip and submit.

OR have a anchor link like this:

<A href="ViewHeading4.jsp?CNT=0&TOTAL=0&formId=FRM-1">Submit</A>

talk2keya at 2007-7-12 20:28:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...