?
Solved

int returned by session

Posted on 2004-04-26
2
Medium Priority
?
395 Views
Last Modified: 2010-04-01
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.directory.*, javax.naming.*, javax.servlet.http.HttpSession, javax.servlet.jsp.*" %>

<%
...
        try {
...
                    if (knownURL.equals(awsAppentryURL)) {
                        out.println("<p>Legal: Token Matched!</p>");
// set sessions here
                        session.setAttribute("calSID",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("UserLevel","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("UserLevel"));

                        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("UserLevel"));
//==it prints but it'll blow up below==
Integer uAccessLevel = (Integer)session.getAttribute("UserLevel");
%>
========================================================
please, appreciate any help!

mskim100
0
Comment
Question by:mskim100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 1000 total points
ID: 10923020
Integer uAccessLevel = new Integer((String) session.getAttribute("UserLevel"));
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 10923022
OR:

session.setAttribute("UserLevel",new Integer(0));


then:

Integer uAccessLevel = (Integer)session.getAttribute("UserLevel");
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
The Summer 2017 Scholarship Winners have been announced!
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question