Get session in JSP

I have got a problem, would like to seek help. thanks in advance:P
HttpSession httpsession=request.getSession(true);
httpsession.setAttribute("user", getUser(userid));//getUser(userid) will return a user
User user=(User)httpsession.getAttribute("user");
i have set a session for a user in a class and i can get the user in the same class, but how can i get the user in JSP??
i have tried as follows:
<% HttpSession httpsession=request.getSession(true);
User user=(User)httpsession.getAttribute("user");
if (user.getRole().equals("user")){ %>
but when i compile the JSP, it said "User not found"
what wrong with the code??
it seems that can't call a bean

Hi,
You are using a custom 'User' class, so need to import it. Add this line at the top of the JSP page:
<%@ page import="pack.name.User" %>
// put the fully qualified User class name hereif you already have the <%@ page %> directive, just add the import attribute to it.
-Srinath

Similar Messages

  • Want to get ApEx session in JSP

    Hi Pals,
    From my ApEx application, I am calling a JSP by providing a direct URL.
    THe JSP does some specific function here.
    If the user get the JSP url by right click and view source, they can very well use this outside my ApEx application.
    I want to apply security like, the JSP url only works inside my ApEx application.
    My thought, if I can share ApEx session with JSP session I can impose the security check in JSP level.
    Any idea would be appreciable.

    Hi,
    Im using below method to call jsp page and passing UserName, application id and Session as
    <iframe src="http://apex.oracle.com/pls/otn/...javaapplication.jsp?userId=&USER.&appId=&APP_ID.&sessId=&SESSION."></iframe>
    Vailidation is done against the table "wwv_flow_sessions$" of schema : flows_030100 ,whether those values are exist in table.
    But if user is already logged into apex application, he can run the jsp independantly taking the url from "view source".
    Im also looking for more solid validation
    Regards,
    Benz

  • Getting Session Info In A Normal Class

    I want to get session info from a class that is not servlet (generally from in a bean). When we use servlets it is so easy to get session info by just using request.getSession() method. Is it possible to get this session info in a normal class which is not servlet Technology?

    Is it possible to get this session info in a normal class which is not >servlet Technology? No reason you cannot.
    But do remember that normal java classes which arent Servlets/Jsps arent invoked by the container as part of the standard request processing.
    Beans, for example, are instantiated (& reused) from within a Servlet or a Jsp.
    So all you have to do is retrieve the session info (or a part thereof) from within a Servlet/Jsp that's part of the request cycle and pass this data onto the bean when you invoke its methods.
    ram.

  • Sessions in jsps

    how to set & get sessions parameters in jsp / servlets.
    thanx

    i know the methods setAttribute() & getAttribute().
    what i wanted to know is like request.setAttribute & request.getAttribute() does session.setAttribute() & session.getAttribute() is corect or not?????????
    if i do session.setAttribute("Test","Test1") in a JSP/servlet then can i do session.getAttribute("Test') in another jsp/servlet

  • How can i get session object based on session id?

    I have tried searching in forum but i can't find any solution that i can get session object based on session id and i also would like to know how to check whether the session is still active? My company currently using weblogic 5.1. I really hope that some one or anyone can help. I am new in using Servlet. I hope that i can find some answer here. Thank you.

    I have a need to get a Session object from a session id, so I don't think that the above should be deprecated. Here is my use case:
    0. I am displaying files in a file list
    1. I am downloading files.
    2. I am downloading files through a Servlet
    3. I am displaying the files as images in an applet
    4. The applet is ImageJ, and it apparently uses a full URL to download the file.
    5. I use request.getRequestURL() in the applet .jsp to get the full URL (the hostname and port)
    6. My app server is OC4J and it's behind an apache server and is host aliased.
    7. Thus the hostname is different between my applet .jsp and the Servlet URLs
    8. Thus I have 2 different sessions
    9. Thus I need to pass the session id (or some other unique identifier).
    10. I could stored the unique identifier in the application object, but then I would need to clean it up
    11. I cannot pass the the full path to the image due to security problems (what if someone downloads my password file?)
    12. I would like this to work in a clustered environment
    13. I think that WebDAV would solve my problems, since I could pass a full URL of webDAV to ImageJ for download. However, I am unsure how the security of WebDAV would work with ImageJ/URLConnection. I will have to research this feature in ImageJ.

  • Handling Session in jsp and bean scope

    i have problems with handling session in jsp
    I want to check on all jsp pages
    first thing is session is null
    i want to him to be redirected to first page
    and he should not be able to go ahead
    I tried
    if(session ==null)
    response.sendRedirect("Login.jsp");
    but this does not seem to work
    It is very crtical problem can any one answer
    this asap
    Also i wanted to know that
    I have bean which in turn calls static methods of another class which holds all DomainTable(database tables which do not change frequently)
    Information .
    This is bean is being implemented by me
    in seession scope in a jsp
    Do u guys think it would be goo idea to change
    scop of this bean as Application in jsp
    if so what would be advantages for same
    I would appericate if i could a quick reply on both
    question
    as i am time crunch
    arsh

    You will always get some value of session and your code wont work. At the end of your Login.jsp, you should create a sesssion and store attributes. Check for these attributes in session, rather than checking session==null.

  • Maintain session in JSP frame

    Hi,
    I am having trouble in maintaining session in jsp frames. -
    Here is sample code
    parent.jsp
    <HTML>
    <HEAD>
    <LINK rel=stylesheet type="text/css" href="defaults.css">
    <TITLE>abc</TITLE>
    <%     
         String checkAmount = "100.00";
         session.setAttribute("checkAmount", checkAmount);
         System.out.println("checkAmount in ppmain"+session.getAttribute("checkAmount"));
    %>
    <FRAMESET rows="235,*" frameborder="no" >     
    <FRAME NAME="pptop" SRC="top.jsp" frameborder=0 scrolling=no noresize >
    <FRAME NAME="ppbottom" SRC="bottom.jsp" frameborder=0 scrolling=no marginwidth=0 marginheight=0 noresize>
    </FRAMESET>
    </HTML>
    top.jsp -
    <HTML>
    <HEAD>
    <LINK rel=stylesheet type="text/css" href="defaults.css">
    <TITLE>top</TITLE>
    <%     
    System.out.println("session in top "+session);
    System.out.println("checkAmount in top "+session.getAttribute("checkAmount"));
    %>
    </HTML>
    It is not able to retain session in the top.jsp ( in SOP for session I get different session ID in parent.jsp and top.jsp
    This Works well in local but when gets deployed to WAS6 server troubles starts.
    Any help is appreciated.
    Thanks

    When you create URLs, you might want to try using JSTL to rewrite them:
    <FRAME NAME="pptop"
           SRC="<c:url value='top.jsp'/>"
           frameborder=0
           scrolling=no
           noresize >
    <FRAME NAME="ppbottom"
           SRC="<c:url value='bottom.jsp'/>"
           frameborder=0
           scrolling=no
           marginwidth=0
           marginheight=0
           noresize>Or you can use:
    SRC='<%= response.encodeURL("top.jsp") %>'

  • URGET!!! Get Session Attribute On Form

    Hi alls,
    I develope application with Forms 9i and JSP.My Application Program is developed by Forms 9i but Menu,that call application program,is developed by JSP.I knew that if I want to call a Form from JSP,I have to append &otherparams on URL.
    My Problems is :
    1.I want to get some parameters,is seted to session attribute in JSP,from Menu to Forms and don't let the users to see these parameters on URL. HOW CAN I DO? (URGENT!!!!)
    2.If I want the Menu always display on top and application display on botton of browser. HOW CAN I DO?
    Thank you for advance.
    PS. Menu develop in dropdown style,it will expand(drop) when move mouse on it.

    Hi,
    1.I want to get some parameters,is seted to session attribute in JSP,from Menu to Forms and don't let the users to see these parameters on URL. HOW CAN I DO? (URGENT!!!!)
    You can't get session attribute from Forms because it runs as an Applet in the browser and does not have access to the server side request object.
    You can access request parameters that are used to call Forms, but that's it.
    2.If I want the Menu always display on top and application display on botton of browser. HOW CAN I DO?
    Use HTML frames
    Frank

  • Unable to get the AppsLocalLogin.jsp page

    Hi,
    We are on oracle Db 11.2.0.2 and EBS : 11.5.10.2 on Solaris Sparc 64 Bit 5.10.
    We have recently added a web node to an existing setup.
    Although Apache services are up , but we are unable to get the AppsLocalLogin.jsp page.
    Replacing the domain name and Ip in line 4  with HOSTNAME.DOMAIN_NAME/IPADDRESS
    We have found the below error in the Jserv log :
    [12/04/2012 20:09:38:868 IST] <info> ApacheJServ/1.1.2 is starting...
    [12/04/2012 20:09:38:868 IST] <debug> using confFile /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties
    [12/04/2012 20:09:39:016 IST] <info> Connection authentication enabled
    [12/04/2012 20:09:39:045 IST] <info> Connection allowed from HOSTNAME.DOMAIN_NAME/IPADDRESS
    [12/04/2012 20:09:39:045 IST] <info> Connection allowed from /127.0.0.1
    [12/04/2012 20:09:39:046 IST] <debug> port 16000 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16001 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16002 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16003 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16004 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16005 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16006 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16007 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16008 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> port 16009 is specified in properties file
    [12/04/2012 20:09:39:046 IST] <debug> try to start on port 16000
    [12/04/2012 20:09:39:050 IST] <debug> try to start on port 16001
    [12/04/2012 20:09:39:050 IST] <debug> cannot create socket on 16000
    [12/04/2012 20:09:39:051 IST] <debug> cannot create socket on 16001
    [12/04/2012 20:09:39:051 IST] <debug> try to start on port 16002
    [12/04/2012 20:09:39:051 IST] <debug> cannot create socket on 16002
    [12/04/2012 20:09:39:051 IST] <debug> try to start on port 16003
    [12/04/2012 20:09:39:051 IST] <debug> cannot create socket on 16003
    [12/04/2012 20:09:39:051 IST] <debug> try to start on port 16004
    [12/04/2012 20:09:39:051 IST] <debug> cannot create socket on 16004
    [12/04/2012 20:09:39:051 IST] <debug> try to start on port 16005
    [12/04/2012 20:09:39:052 IST] <debug> cannot create socket on 16005
    [12/04/2012 20:09:39:052 IST] <debug> try to start on port 16006
    [12/04/2012 20:09:39:052 IST] <debug> cannot create socket on 16006
    [12/04/2012 20:09:39:052 IST] <debug> try to start on port 16007
    [12/04/2012 20:09:39:052 IST] <debug> cannot create socket on 16007
    [12/04/2012 20:09:39:052 IST] <debug> try to start on port 16008
    [12/04/2012 20:09:39:052 IST] <debug> cannot create socket on 16008
    [12/04/2012 20:09:39:052 IST] <debug> try to start on port 16009
    [12/04/2012 20:09:39:052 IST] <debug> cannot create socket on 16009
    ApacheJServ/1.1.2: Failed to bind to port(s) specified in /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties.  Please check /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties and jserv.conf file, and make sure number of JServ process specified in jserv.conf is less than number of ports specified in /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties. and the ports are not used by other processes.
    [12/04/2012 20:09:39:053 IST] <critical> ApacheJServ/1.1.2: Failed to bind to port(s) specified in /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties.  Please check /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties and jserv.conf file, and make sure number of JServ process specified in jserv.conf is less than number of ports specified in /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties. and the ports are not used by other processes.The IP of this web node is different from the IP mentioned in the log, at line 4.
    Regards
    KK

    Hi;
    ApacheJServ/1.1.2: Failed to bind to port(s) specified in /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties. Please check /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties and jserv.conf file, and make sure number of JServ process specified in jserv.conf is less than number of ports specified in /pch3/oracle/external/prdora/iAS/Apache/Jserv/etc/jserv.properties. and the ports are not used by other processes.Please check your port is avaliable or not also check related path
    Regard
    Helios

  • Getting session has timed out while trying to redeem a gift card. have had no problem in the past.  am running a g4 since 2002 with os 10.4 and itunes 9. have no internet problems and can connect to store ok. so far apple no help keeps blaming it on othrs

    am having trouble for the first time trying to redeem a gift card. Everything same on computer, OS, and internet connection. have been able to redeem other cards. this time am getting "SESSION HAS TIMED OUT" while trying to redeem card. have contacted apple and checked out all their suggestion iE:( must be your connection. typed in code wrong, too old version of itunes, etc) anything but why would a gift card code bee tied to a specific vetrsion of ITUNES. Rediculous!! there has to be others out there that have an older version if itune than i have. has anyone ever had the error "SESSION HAS TIMED OUT" and if so was it corrected?? any information other than apples {change password and give us lots of personal info they probably have) would be appreciated..

    Hello,
    As far as I can see, that Verizon Jet Pack wireless Modem uses WPA2 to connect.
    The Router might complicate things right now.
    Make a New Location, Using network locations in Mac OS X ...
    http://support.apple.com/kb/HT2712
    Is that Interface dragged to the top of Network>Show:>Network Port Configurations and checked ON?
    The Interface that connects to the Internet, needs to be drug to the top of System Preferences>Network>Show:>Network Port Configurations and checked ON.
    If using Wifi/Airport...
    Instead of joining your Network from the list, click the WiFi icon at the top, and click join other network. Fill in everything as needed.

  • Session in JSP page

    Hi all,
    i built a web application now i want to use session in JSP pages to remember some variable such as password and entered date because i need them in later pages and i also don't want to send them via HTML hidden field. I actually don't know how to use session. Can anyone please just tell me how to create a session and store a variable and also how to retrieve the data from the session.
    Another thing is guys can anyone tell me please that say i am user and i selected some items from a HTML select list and i submitted that and logged off the system now when i login later again i want to see those choices selected by default , i know it might have been done by sessions can anyone please tell me.
    THANKS VERY MUCH

    This is the way u can set and retrieve values from session
    <% session.setAttribute("key","value"); %>
    <% String user=(String)session.getAttribute("user");
    %>
    regards
    Shanu

  • Why I get "Error in getting session data" error when running report?

    Hello,
    I have reporting services on one server, and SharePoint 2010 on other server. When I view report from browser, I got blank page. From Report Server Log file, I got below error:
    v VERBOSE: writting session cookie: ekkrjbubp00t5wzc3rzspvzb
    v VERBOSE: Saved report snapshot to session in a background thread <for same session id>
    e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.ReportServerStorageException: , An error occurred within the report server database.  This may be due to a connection failure, timeout or low disk condition within the database.;
    e ERROR: Error in getting session data: Expired Session: ekkrjbubp00t5wzc3rzspvzb
    e ERROR: Throwing Microsoft.ReportingServices.Diagnostics.Utilities.ExecutionNotFoundException: , Microsoft.ReportingServices.Diagnostics.Utilities.ExecutionNotFoundException: The report execution ekkrjbubp00t5wzc3rzspvzb has expired or cannot be found
    Are there anyone getting the same issue as mine? I did not see any solutions for this issue when I searched.
    Thanks,
    Megan

    There are a number of timeouts in SSRS; session timeout, report execution timeouts, http request timeouts.  A session timeout in SSRS is not the same as a session timeout in ASP.NET.  Below are some articles that can help you understand the timeouts
    and hopefully lead you down the path of discovery.
    This articles is a good article as it discusses the session timeout and the keep alive that is sent from the report viewer.
    http://blogs.msdn.com/b/jgalla/archive/2006/10/11/session-timeout-during-execution.aspx
    This article is good as well in describing some of the timeouts.
    http://blogs.msdn.com/b/dynamicsaxbi/archive/2013/02/14/how-to-addressing-ssrs-session-timeouts.aspx

  • ERROR: Error in getting session data: Invalid or Expired Session

    Hi,
    We are using ssrs 2008 r2 and have a report which has links that allow the user to drill down.
    When the link is clicked the same report is run but shows more detail. This works fine but we are now getting the error below for a user. 
    I have increased the time out for the report to 600 seconds.
    Error in getting session data: Invalid or Expired Session: fnxgxhjuveugvd552qfyv3fw
    session!ReportServer_0-6!4b0!03/18/2015-10:51:29:: i INFO: LoadSnapshot: Item with session: fnxgxhjuveugvd552qfyv3fw, reportPath: , userName: doman/user not found in the database
    Any ideas how this can be resolved?

    Hi Nasa1999,
    Based on your error message, If the all the users will sometimes got the same issue, it can be caused by the timeout issue. It happens a lot when rendering big report, and it exceeds the default Session Timeout. You can execute script
    to increase the Session Timeout time. Please refer to following blog:
    Session Timeout during execution. Also increase the value of <Query Timeout> in rsreportserver.config file. This file locate at XX:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer
    Please also check to set the <legacyImpersonationPolicy> back to true(https://support.microsoft.com/en-us/kb/972328).
    Locate the Aspnet.config file in the following folder:
     %windir%\Microsoft.NET\Framework64\v2.0.50727
    If Microsoft Visual Studio is installed on the computer that is running SQL Server 2005, double-click
    Aspnet.config. If Visual Studio is not installed on the computer, follow these steps:
            a. Right-click Aspnet.config, point to
    Open with, and then click Choose program.
            b. In the Programs list, click
    Notepad, and then click OK.
    Locate the following tag in the <runtime> section of the code.
            <legacyImpersonationPolicy enabled="false"/>
    Change the tag to:
            <legacyImpersonationPolicy enabled="true"/>
    Save the Aspnet.config file.
    Reset IIS.
    Try your report again.
    Similar Thread for your reference:
    Using SharePoint Report Viewer
    Web Part: Error in getting session data: Invalid or Expired Session: xxxxxxxxxxx
    If only the one user or several users will got the issue, the issue can be caused by the permission setting, please reference to below blog:
    http://answers.flyppdevportal.com/categories/sqlserver/sqlreportingservices.aspx?ID=3506231b-9f4d-4f5a-884d-157137c56336
    http://blog.goobol.com/the-permissions-granted-to-user-domainusername-are-insufficient-for-performing-this-operation/
    If your problem still exists, please try to provide more details information as below:
    Did you reporting service installed in native mode or sharepoint mode, If in native mode, please try to provide more error message from the log file:
    C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\LogFiles
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • How to Handle user Session in JSP

    Help me,
    How to handle user session in JSP.......

    Prakash_Pune wrote:
    tell me some Debugging tech. so i can overcome from my problem.....Do you use an IDE? Any IDE ships with a decent debugger where in you can just execute the code step by step, explore the current variable values and check what exactly is happening. For example Eclipse or IntelliJ. If you don´t use an IDE, then just place some System.out.println() or Logger.debug() statements at strategic locations printing the variables of relevance so that you can track in logs what exactly is happening.
    or tell any other way to find is my page is thread safe or not...Just write correct code and narrow the scope of the variables as much as possible. If you for example assigned the user object to a static variable or as a servlet´s instance variable, then exactly the same user object would be used everywhere in the application. That kind of logical things.

  • Problems using GET method in JSP

    Hi,
    I had some problems using GET method in JSP.
    I'm using Apache web server 1.3 and Tomcat 3.3.1 in windows 2000.
    And I'm using language English and Korean.
    When I send messages using POST method, all is good
    But when I send message using GET method, English is good, but Korean is not good.
    I tried to encode using
    URLEncode.encode(str, "UTF-8")
    and decoding it using
    URLDecode.decode(request.getParameter(tag), "UTF-8")
    but it didn't work.
    How can I receive request including Korean using GET method in JSP?
    If anyone have solutions, please let me know.
    thanks.

    Hi,
    I had some problems using GET method in JSP.
    I'm using Apache web server 1.3 and Tomcat 3.3.1 in
    windows 2000.
    And I'm using language English and Korean.
    When I send messages using POST method, all is good
    But when I send message using GET method, English is
    good, but Korean is not good.
    I tried to encode using
    URLEncode.encode(str, "UTF-8")
    and decoding it using
    URLDecode.decode(request.getParameter(tag), "UTF-8")
    but it didn't work.
    How can I receive request including Korean using GET
    method in JSP?
    If anyone have solutions, please let me know.
    thanks.This problem appears, when one use UTF-16 encoding in JSP - am I right?
    If so there are two solutions:
    1) Temporary: Use "UTF-8" - or any other 8 bit encoding scheme and
    encode Korean symbols with "&1234;" kind of escapes - though it
    may not work
    2) Absolute: get my piece of code, which I have managed to write
    just a month ago resolving absolutely similar problem with UTF-16
    in code using Chinese/Russian/English encodings
    But I wouldn't say that it's costs 10 DDs :) - it's much more
    expensive... So try 1st variant if it wouldn't help - let me know.
    I'll figure :)
    Paul

Maybe you are looking for

  • Sudden System Slowdown

    Today, inexplicably, my system has slowed down dramatically. I'll double-click on a folder, it'll wait a second, then open. I'll scroll my mouse wheel, it'll wait a second, then scroll. I'll hover over the dock, it'll wait a second, then jerkily appe

  • Finding Application Module name in read-only view object classes

    Hi all, I have a fairly basic question about finding application module name when we are coding in ViewObject java classes. I want to know how can I obtain <<application module>> NAME that our current view object is contained in it at run-time. I thi

  • Schedule report re-runs when opening

    Hi, I have a scheduled discover report in Discoverer 4.1.48 version, when opening that scheduled report its re-run the query again. Please let me know, the reason. BR, Uma

  • IMac says "You can't open the application iTunes because it is not supported on this type of Mac."

    I am running a 2006 iMac with Mac OS X 10.6.8 (it will not update to any newer OS).  Is it possible my iTunes updated to a version that can't work on this OS?  Why would my iMac allow that?  What can I do to fix it?  Is it possible to download an old

  • LR5 Export to Nik HDR Efex Pro 2

    Win 7, 64 bit, LR5.2RC, Nik HDR Efe Pro 2.... From Export > HDR Efex Pro 2 it used to pause at a screen providing three choices (from memory), "as copy with LR adjustments", "as copy without LR adjustments" or "as orignal".  Now it skips that screen