I'm calling a servlet from another :
pw.println("<tr><td><a target=\"new\" href='/servlet/threedstr?pid='fromdata'&spos='spos'&epos='epos'&cmd=5'> 3D Structure</a></td></tr>");
where the parameters pid,spos and epos are to be sent dynamically with the values in the corresponding variables.
But it is giving a runtime error: Number Format Exception.
Can someone tell me if this is the right way to pass values in variables as parameters?
Originally posted by Andrey Orekhov:
As it seems from the exception, in the called servlet you try to read parameter value into numeric variable, but all parameter values are Strings in fact. So you need to take extra step and parse parameter string to extract number. Something like int paramA = Integer.parseInt(paramAValue);
The exception will occur at the exact point where chaitanya would attempt something of this sort
"int paramA = Integer.parseInt(paramAValue);"
as in the query string that he is passing
(" pid='fromdata'&spos='spos'&epos='epos' ")
the values of pid,spos,and epos that will be passed will be "fromdata","spos" and "epos" respectively and not their numeric values as it is intended to be.
the single quote usage would not pick the numeric values for the pid,spos,and epos and hence need to be replaced with the URl using ".