Hi Vijay,
The problem with your code is , the JSP compiler is already have some meaning for the keywork "session", here you are using the keyword as a variable(as you know "WE SHOULD NOT USE KEYWORDS AS VARIABLE NAMES").
Try to use another name like
<%
HttpSession sess = request.getSession();
String myAttr="";
sess.setAttribute("myAttr","test");
%>
It Works..
Hope you are clear what i said.