Use the getAttribute method of the HttpServletRequest object
Use the getAttribute method of the HttpServletRequest object to return a temperature value as an Integer, cast the returned value from the getAttribute method from an object to an integer. Then print the temperature value using the System.out.println method. Assume that the HttpServletRequest object is named request.
Solution
Hi, Please find my code snippt.
I am assuming that : temperature is available in \'HttpServletRequest\' with name \'temperature\'
- getAttribute return String
// getting temperature as String
String strTemp = request.getAttribute(\"temperature\");
// converting in Integer Object
Integer intTemp = new Integer(strTemp);
// printing
System.out.println(intTemp);
