"dolobran" <> skrev i en meddelelse
news: ups.com...
> I am trying to get the key value from a Map and cast to a String.
Are you sure that is what you are trying to do? Your use if the terms is a
little ambiguous also: with a map one talks about "keys" and "values"; to
talk about "key values" is a bit confusing.
> I am getting a class cast exception.
>
> Map queryArgs = request.getParameterMap();
>
> urlSurveyIdInt = ((Integer) session.getAttribute("surveyid")
> ).intValue();
This is not from the request. Are you trying to get it from the session
(HttpSession) ?
> The intended behavior is to capture the URL parameter surveyid value
> from a URL such as this:
>
> http://myDomain.com/survey.jsp?surveyid=1
> Can someone help?
Something like this?
String s = request.getParameter( "surveyid" );
if ( s != null ) {
int i = Integer.parseInt( s );
}
(Could still get a NumberFormatException if the string is not convertible).