Skip to content
Advertisement

Storing integer as attribute in jsp

I want to pass an Integer value as an attribute in JSP. But when i try

int i = Integer.parseInt(request.getAttribute("count"));

an error is returned. Could you tell me a method to store Integer numbers as attributes in JSP?

I am getting a casting error saying parseInt() is not suited for handling objects.

Advertisement

Answer

request.getAttribute returns an Object. you need to cast this to String like this:

Integer.parseInt((String)request.getAttribute("count"));
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement