Sessions within JSP's

I have a JSP with a number of beans declared as session beans.
I then include (JSP:INCLUDE) a servlet which then tries to access one of the session beans.
To check how things are going I do the following within the servlet:
     // Retreives session Object
     HttpSession session = req.getSession(true);
if (session == null) {
printTrace("Failed to get the Session!");
if (session.isNew()) {
printTrace("A new session was created!");
I always get the "A new session was created!" reply.
When I return to the JSP, any information that had been set up in the servlet does not appear in the session.
It appears that the JSP has created another session, different from the servlets session and all the beans are in their initial state.
QUESTION:
     Could someone point me towards some information on when the session is created in a JSP?
Regards
Phil

I have a JSP with a number of beans declared as
session beans.
I then include (JSP:INCLUDE) a servlet which then
tries to access one of the session beans.
To check how things are going I do the following
within the servlet:
// Retreives session Object
HttpSession session = req.getSession(true);
if (session == null) {
printTrace("Failed to get the
("Failed to get the Session!");
if (session.isNew()) {
printTrace("A new session was
("A new session was created!");
I always get the "A new session was created!" reply.
When I return to the JSP, any information that had
been set up in the servlet does not appear in the
session.
It appears that the JSP has created another session,
different from the servlets session and all the beans
are in their initial state.
QUESTION:
Could someone point me towards some information on
when the session is created in a JSP?
Regards
PhilTry HttpSession session = req.getSession(false);
When you pass true, it will create a new session if one does not exist. thats why you get "A new session was created!" all the time.
regards
Stef

Similar Messages

  • Can EJB's be called from within JSP pages?

    Hi,
    (This is a general question, not necessarily related to OAS in any way...)
    I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
    Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
    Any help would be appreciated. Thanks!
    David Christopher
    [email protected]

    Hi,
    Check the following code: http://www.jguru.com/jguru/faq/view.jsp?EID=5314 for ejb example.
    -Ruchi
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Davidc:
    Hi,
    (This is a general question, not necessarily related to OAS in any way...)
    I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
    Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
    Any help would be appreciated. Thanks!
    David Christopher
    [email protected]<HR></BLOCKQUOTE>
    null

  • Create java session within portlet

    We are integrating our application JSP/Servlet/Beans to 9ias R2. URL portlet is out of question, so how would it be possible to create java session within a java portlet, then accessed by the application, which sits at different instance? An example will be great.
    Thanks

    HI Jim,
    You can refer to "adding.session.storage.pdk.java.v2.html" document - a part of PDK download. This doc might be of use.
    Thanks,
    Ravi

  • How to create a different browser session within the same profile

    Internet Explorer 8 lets you create a new session within a new browser window but how can I do the same with Firefox? I know if you switch user profiles then you can have two browsers in different sessions but I would like to have two sessions using the same user profile.

    Sorry, that's not possible with Firefox. Firefox uses a single executable instance to run all windows and tabs, where IE starts another process for each window. Chrome uses a separate process for each tab (or window), which seems real nice until it sucks the life out of an older processor with the "overhead" of all those separate processes.
    Depending upon what you want a "different session" for, there are 3 extensions that allow for multiple cookie sessions which allow for multiple, simultaneous logins to the same server. That works to allow the user to log into multiple webmail accounts at the same service provider. <br />
    Multifox: <br />
    http://br.mozdev.org/multifox/ <br />
    Cookie Swap extension: <br />
    https://addons.mozilla.org/firefox/3255/ <br />
    Cookie Pie extension: <br />
    http://www.nektra.com/oss/firefox/extensions/cookiepie/

  • 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

  • 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.

  • How can we call java control source methods within jsp

    Hi guys!
              How can we access java control source methods that are defined in java control projects within jsp.I am getting error when I tried to call java control source's methods in scriptlet of JSP page.Any help/suggestion is appreciated.
              Thanks
              -Chandu

    Uh, what?
    (And you are sure that it's not a Weblogic-specific question?)

  • How to clear session in JSP?

    I searched yahoo, and found that it seemed not easy to force invalid the session using jsp, compared to php just three lines:
    session_start();
    session_unset();
    session_destroy();
    How to acheive this using JSP? Must I follow these (quite complex) steps like this one?
    http://sdc.sun.co.jp/javasystem/technote/cluster/jsp.html
    Any simplier method?
    Thx.

    Not at all, it's very simple.
    <%
    session.removeAttribute("attributeName");
    %>
    This HttpSession API document shows all methods that can be called on the session object : http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html

  • What is the use of session in jsp

    hai,
    what is the use of session in jsp. i cant understand from books. give some practical approach
    thanks

    give some practical approachYou sound like a supervisor ordering for a cup of coffee.
    I DONT TAKE ORDERS !!
    IMAO
    Which book did you refer ? Did you google ?

  • 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

  • Making  a session in jsp.

    I want ti make a session in jsp.
    suppose if any budy can login through login page which is
    www.harshworld.info/login.jsp
    they will just direct open that page
    www.harshworld.info/wallpage.jsp
    then this page will not open . & user will see The login page it self.
    So after making session in jsp what can i do ?
    & how to Do can one help me.
    PL Thanks for Giving time to me

    THk dear
    there's always a session...
    if(session.getAttribute("username") == null) {
    response.sendRedirect("login.jsp");
    return;
    and put the attribute in the session on successful
    login..
    Or look up other security modes.

  • 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") %>'

  • Restore sessions within another "restore session" window

    SOS!!! Yesterday I opened firefox through a link in my email. The window opened with two tabs: one is the new link I opened and the other one is for restoring my previous sessions from earlier time. Since firefox was working a bit strangely so I tried to open the new link several times. Now problem happened. When I try to restore sessions, it only restores to the last one I had with just two tabs. Even though I kept clicking on "restore session" within the restore session window, it won't show all my previous tabs information but stuck with the two tabs lastly seen. And it continue to repeat these two tabs no matter how I choose (even by deactivating the new tab window, it still doesn't restore to original status). I thought by shutting down my computer completely, maybe firefox will go back to my previous settings, but this morning when I turned it back on, it still stick with the last two tabs opened yesterday. Where can I find all the old tabs I used to saved? SOS!!!

    Is the History > Recently Closed Windows (or Tabs) item available ?

  • Dealing with multiples windows within a session (servlets & JSPs)

    Hi,
    How can I show multiple windows during a session and avoid terminating the current session when one of those windows is closed?
    I have a main window through which the client navigates from page to page using servlets and JSPs. But if he opens the help window (via a <a href ... target="_blank"> and then closes the help window, the session is lost and the server doesn't recognizes the client anymore and creates a new session.
    Can someone help?
    Jean Vaillancourt, Montrial

    Hallo,
    how long is session-timeout and what do u do in your application ??
    Sanjay

Maybe you are looking for

  • How come My Sites can only be created when logged directly onto the Sharepoint Server?

    Hello Community    In Synchronization I populate the container with OU's that contain Service accounts, user accounts created in the Sharepoint farm and a domain local group containing a OU with all of the trusted user accounts.    AFter populating t

  • Error while copying GL Accounts from One Client to another client

    Hi, We are trying to copy GL accounts created in one client to another client (Company Code is same in both the clients). First we executed FS15 (send) and a file was created on the server. With the help of BASIS team we checked that file and it cont

  • Cannot copy RAW images to Tiff or Jpeg in ACR

    Requesting immediate help if anyone available currently I've been using Photoshop CS6 for several years, never a problem at all. As soon as I bought Creative Cloud, I see many issues that cannot be resolved or are recurring. Again today as I go to co

  • Is there still a way to send an email to phone?

    I have a few pictures in my email I want to forward to my friend's verizon phone. I tried the [email protected] and the [email protected] I've used these email addresses many times but it looks like they aren't working now. I just found this page htt

  • First Flash Site

    Calling Flash Gurus- I am building my FIRST flash site. I have been doing effects, headers, and basic flash elements for websites now for almost 2 years. I have MX 2004, but have just bought (today) Studio 8. I am scared to death, but sometime I have