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?
# 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>