mskim100
asked on
int returned by session
well, it seems that i'm having real hard time working with integers in jsp.
i set a variable, ie. uid = "100", and i do use quotes since the program was yelling at me. but when i try to get it back in another jsp page, it wont let me cast it to an integer.
so setting my session:
========================== ========== ========== =========
<%@ page import="java.io.*, java.sql.*, java.util.*, java.lang.*" %>
<%@ page import="javax.naming.direc tory.*, javax.naming.*, javax.servlet.http.HttpSes sion, javax.servlet.jsp.*" %>
<%
...
try {
...
if (knownURL.equals(awsAppent ryURL)) {
out.println("<p>Legal: Token Matched!</p>");
// set sessions here
session.setAttribute("calS ID",awsUid );
out.println("SID session: " + session.getAttribute("UID" ));
//user level
// only students get their access here. so set the user access level to 0
session.setAttribute("User Level","0" );
//===i tried to set this attribute with 0 without quotes but it wouldn't let me.===
out.println("cal access level session: " + session.getAttribute("User Level"));
out.println("session creation time: " + session.getCreationTime()) ;
//===i get everything printed on screen===
} else {
out.println("Illegal Access! The Tokens did not match!");
}
}
} catch (IOException e) {
throw new JspTagException("I/O Exception, " + e );
}
} catch (Exception e) {
throw new IOException("Exception, " + e);
}
}
%>
========================== ========== ========== ========
and i can print out all the sessions. so trying to use them in my other jsp page:
========================== ========== ========== ==========
<%@ page import="java.util.*..." %>
<%
out.println("what's my sid here? " + session.getAttribute("UID" ));
out.println("what's my user level here? " + session.getAttribute("User Level"));
//==it prints but it'll blow up below==
Integer uAccessLevel = (Integer)session.getAttrib ute("UserL evel");
%>
========================== ========== ========== ==========
please, appreciate any help!
mskim100
i set a variable, ie. uid = "100", and i do use quotes since the program was yelling at me. but when i try to get it back in another jsp page, it wont let me cast it to an integer.
so setting my session:
==========================
<%@ page import="java.io.*, java.sql.*, java.util.*, java.lang.*" %>
<%@ page import="javax.naming.direc
<%
...
try {
...
if (knownURL.equals(awsAppent
out.println("<p>Legal: Token Matched!</p>");
// set sessions here
session.setAttribute("calS
out.println("SID session: " + session.getAttribute("UID"
//user level
// only students get their access here. so set the user access level to 0
session.setAttribute("User
//===i tried to set this attribute with 0 without quotes but it wouldn't let me.===
out.println("cal access level session: " + session.getAttribute("User
out.println("session creation time: " + session.getCreationTime())
//===i get everything printed on screen===
} else {
out.println("Illegal Access! The Tokens did not match!");
}
}
} catch (IOException e) {
throw new JspTagException("I/O Exception, " + e );
}
} catch (Exception e) {
throw new IOException("Exception, " + e);
}
}
%>
==========================
and i can print out all the sessions. so trying to use them in my other jsp page:
==========================
<%@ page import="java.util.*..." %>
<%
out.println("what's my sid here? " + session.getAttribute("UID"
out.println("what's my user level here? " + session.getAttribute("User
//==it prints but it'll blow up below==
Integer uAccessLevel = (Integer)session.getAttrib
%>
==========================
please, appreciate any help!
mskim100
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
session.setAttribute("User
then:
Integer uAccessLevel = (Integer)session.getAttrib