HttpSessionContext and HttpSession

hi,
With all the knowledge i gathered from here and there about sessions - to be frank i am very confused.
1>Can someone please explain to me why and how HTTPSEssionContext is used
2> I am using about 6 servlets, where each servlet is creating a separate dynamic web page.
The first servlet is one which creates a login page. Once i create the login page, i get the id which has to be carried through the different servlets. This is easy, as i can pass query string parameter. My problem is that in between the third and the fourth servlet, i call a static html page. Once i get the static page, then i am not able to pass the id anymore. Can someone tell me how to do it?
3>The command
HttpSession sesStore = req.getSession(true);
Is this given when i create a new session. ie) in the above example, the first servlet. When the second servlet is called,
HttpSession sesStore = req.getSession(false);
i have to change the true to false, Right
A bit confused
Please throw some light
Pratibha

SessionContext is used to figure out the environment in which the servlet is running. For example, if there are configuration variables that have been set, you can call
String val = getInitParameter( "ParmName" );Going to a static HTML page is not a problem if you use cookies for storing the session key. The browser doesn't know what is dynamic and what is static so it passes the cookie along on every request, so you have no worries there.
As far as the getSession() methods, I have had no end of frustration with those. I have never seen them actually work according to documentation. As far as I can tell, getSession( true ) always creates a new session, but the docs suggest that it won't make a new one if there is already one there. I have had nothing but inconsistent results with the getSession() method (no parameters).
On my projects I have ended up doing a getSession(true) during login, and then getSession(false) for the rest of the time.

Similar Messages

  • Problem with HttpURLConnection and HttpSession.

    Hi,
    Problem with HttpURLConnection and HttpSession.
    I created a HttpSession object in my main class and then called a URL via HttpURLConnection.
    I tried to access the same session object from the servlet called by the URL . but the main session
    is not returned a new seperate session is created.let me know how can we continue the same session in
    the called URL also which is created in main class.
    Thanks
    Prasad

    You are not supported to create a HttpSession by java client. Only J2EE web container can create it.

  • XSQL and HttpSession object availability

    Hello,
    How to access the very convenient unique HttpSession unique ID?
    The one we have this way within a servlet:
    HttpSession session = request.getSession(true);
    System.out.println(session.getId());
    Thank You in advance
    JRoch
    null

    You can access this easily by writing a custom action handler. Here is the code for a custom action handler that sets the value of the Http Session id into a page parameter named "session-id".
    import oracle.xml.xsql.*;
    import java.sql.SQLException;
    import org.w3c.dom.Node;
    import javax.servlet.http.*;
    public class GetSessionId extends XSQLActionHandlerImpl {
    public void handleAction( Node rootNode ) throws SQLException {
    XSQLPageRequest req = getPageRequest();
    if (req.getRequestType().equals("Servlet")) {
    HttpSession sess =
    ((XSQLServletPageRequest)req).getHttpServletRequest().getSession(true);
    if (sess != null) {
    req.setPageParam("session-id",sess.getId());
    }Then from within your XSQL page, you can say:
    <xsql:action handler="GetSessionId"/>
    and then later in the page refer to the parameter named session-id to access it's value as a lexical or bind parameter.

  • Struts and HttpSession

    Hi guys, i think this is not te correct forum to ask about struts, but i realy need some help with that, i need to get the ID of a Http session and use this ID inte action class of struts for others task, can anyone help me on how to get the http session id from struts 2
    thanks in advance

    Use HttpSession.getId() [1]. Make it a point to read the documentation, you'll get more than enough help there and you'll learn as well.
    [1] http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpSession.html#getId()
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • IE6 and HttpSession

    My JSP's/Servlets use simple HttpSession objects that expire when the browser is closed. It is my understanding that if a browser has cookies disabled that URL rewriting is used. I've been testing in IE6 and when cookies are restricted all my session objects are all null. So it appears URL writing isn't occuring.
    Is there anything I have to do to 'turn on' URL rewriting? Any other suggestions?

    Hi Jason,
    Read this:
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q293222
    http://support.microsoft.com/support/kb/articles/q293/2/22.asp?LN=EN-US&SD=gn&FR=0&qry=cookie&rnk=10&src=DHCS_MSPSS_gn_SRCH&SPR=IE600
    --Paul                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • OracleAS 9.0.4 Clustering and HttpSession

    Does OracleAS 9.0.4 Clustering replicate HttpSession state between cluster nodes or just stateful session bean state?
    Thanks
    Bill

    "Checking operating system version: must be 5200 Failed <<<<"
    So don't install this version on AIX 5.3. AS 9.0.4 has been desupported. Please don't get yourself into the hell of installing it and especially not on AIX.
    Install 10.1.2.0.2, and not before you have read the certification notes on MetaLink and taken every step you need to install on this challenging platform!

  • Authorized Users for J2EE's Deploytool and HttpSession queries!!

    Hi guys,
         i need some information about HttpSession, and J2EE's deploytool. First, i know how to use deploytool from the J2EE tutorial and it a good one but my assignment requireds more than that. I would like to know how to allow only authorized user to use an jsp(very impt jsp, that means).
         Secondly, my servlet had set some attributes on a HttpSession so to forward to a jsp so I requires some session tracking. But when the user click on the 'Back' button on the I.E. The information remains there. I tried to set attribute on a HttpRequest but my jsp fails to get the information. This problem really pull me back. :-(
    I really appreciate if there is any links or more advanced J2EE tutorials so i can visit them and solved my problems. Examples are welcome toooo. Thanks guys!!

    try http://jakarta.apache.org/struts for some
    sophisticated examples.
    and for setting an attribute on a request. This only
    works when transferring from one servlet to another
    without sending anything to the browser. Requests are
    stateless, so if you set an attribute, the next time
    it will not be there, since it is not saved. If you
    want to save user information you can:
    - create a hidden field on a form and put the
    information there
    - set the information you want to save in a cookie
    - set the information you want to save in the session
    object.

  • Servlets, JSESSIONID, and HttpSession

    I have a clustered WL7 environment setup. The app uses:
    ServletAuthentication.weak(user,pass,request);
    To ensure that the userid is correct. It successfully authenticates and sets
    the JSESSIONID cookie value on the admin server and going back to the same
    server is no problem but when I invoke the servlet on the other server
    within the cluster, there's no JSESSIONID cookie and so the user is not
    authorized.
    Any pointers, tips would be apprechiated.
    Thanks

    Web Server 6.0 docs collection is in : http://docs.sun.com/app/docs/coll/S1_ipwebsrvree60_en
    Planet Web Server 6.0, Enterprise Edition Programmer's Guide to Servlets http://docs.sun.com/app/docs/doc/816-5689-10
    If possible upgrade to Web Server 7.0 Update 2 from :
    http://www.sun.com/download/index.jsp?cat=Web%20%26%20Proxy%20Servers&tab=3&subcat=Web%20Servers
    docs collection:
    http://docs.sun.com/app/docs/coll/1653.2
    Sun Java System Web Server 7.0 Update 2 Developer's Guide to Java Web Applications
    http://docs.sun.com/app/docs/doc/820-2207

  • WAP and HttpSession

    Hi to everyone
    I am a beginner in JSP and WAP and I have a little question. maybe you'll know the answer.
    I have wrote a simple wap applications with 2 JSP. Every JSP file prints the session id, using the command:
    <%= request.getSession().getId() %>
    I expected that the session id remains constant when one jsp move the control to another jsp, but I saw that it is changed (even if I just do a simple refresh)
    My questions are:
    1. Should the session id remain constant ?
    2. If the answer is yes, why is it changed with WAP? As much as I know, cellcom saves coockies.
    3. Is there another way to identify users?

    I read about URL rewriting. If I understand it correctly, I should use the method response.encodeURL(myUrl). I did it but it didn't help - maybe I had a mistake.
    Here is the relevant code:
    <do type="accept" label="Password">
    <go href= <%= response.encodeURL("http://myurl:9080/wml/Login?user=$user&password=$password") %> />
    </do>
    Why isn't it work? Where am I wrong?
    Maybe I can't use rewriting with dtnamic URL?

  • Cookies and HttpSession

    Hi,
              Will HttpSession work even if cookies are turned off in the browser? For
              this, What is the setting in the weblogic server?
              Thanks,
              Harish
              

    Look for something to do with "use url encoding".
              Cameron Pudy
              "Harish S K" <[email protected]> wrote in message
              news:[email protected]..
              > Hi,
              >
              > Will HttpSession work even if cookies are turned off in the browser? For
              > this, What is the setting in the weblogic server?
              >
              > Thanks,
              > Harish
              >
              

  • UIX and HttpSessions

    After handling http events, with HttpSessionListener interface, i noticed that every request against my uix pages are creating new http sessions.
    I look for all getSession(true) in my code, and have replaced for getSession().
    But it still persists creating new http session at every single uix request.
    Even if i call an uix page directly without passing the request to struts actions, it create new sessions.
    I'm using uix templates.
    JDev 10.1.2.0.0 ( Build 1811 )
    ADF UIX, ADF Struts, BC4J
    Very Thanks;
    haaaa, Steave congratulations for your new adf toy story release, great job;

    Thanks Deepak;
    But i really don't think that getSession is the cause any more.
    The main point is that when i call an uix page WITHOUT templates it does not create any session; and when i call an uix page based on any template it creates;
    Working on it i found this from uix developer guide;
    Templates are loaded by a new section of the UIX Servlet <page> element: <templates>. Unlike most sub-elements of <page>, this element must be placed in the UIX Components namespace: .......
    But i really don't know if it is an normal , and really i don't think so.
    Perhaps some thing i'm missing related namespaces (topic that i don't understand until now, if someone has any link i'll apreciate);
    Thanks again;

  • JAAS and HTTPSession

    It seems that every time i switch from jaas-secured to non-secured realms in my app the session is destroyed.
    Is this the right behavior?
    Is there a way to share sessions between the realms?
    Thanks!

    i have similar problem like urs .....
    i want to restrict call to the java methods based on the user roles
    i think this can be done using session bean ....
    but how is the question ...
    if u find some answer please inform me as well
    on my id
    [email protected]
    thanks in advance

  • Is WL6's ServletContext and HttpSession implementation Serializable?

    As the subject stated
              Rgds,
              Raymond Mok
              

    No, they are not serializable.
              mark
              Raymond Mok wrote:
              > As the subject stated
              >
              > Rgds,
              > Raymond Mok
              

  • Can't get rid of Deprecated Warnings when implementing HttpSession

    We are implementing HttpSession, for a mock object for testing. However, it has methods that access a deprecated class (HttpSessionContext). Although we mark our implementation of the method that accesses this class (getSessionContext) with the annotation @Deprecated, we still get two error messages as follows:
    Warning:Warning:line (8)[deprecation] javax.servlet.http.HttpSessionContext in javax.servlet.http has been deprecated
    One warning comes up on the import line for the interface HttpSessionContext, and one on the declaration of the getSessionContext method.
    We are using Java 5, with the -deprecation flag.
    Is there no way to get rid of these warning messages every time we compile? (We can't turn off the flag just for this one class, because we are compiling from within an IDE (IDEA) that doesn't seem to give us that option.)
    Thanks.
    Dan Cooperstock, Senior Software Developer, Quest Software
    260 King St. E., Toronto ON Canada M5A 4L5
    [email protected] 416-933-5165
    With Quest Software, you get more ... more performance, more productivity, more value from your IT investments.
    Visit www.quest.com to learn more.

    @SuppressWarnings("deprecation")

  • Urgent: Problems with HttpSessions in weblogic 5.1

    Hi,
              I am work with Weblogic 5.1, Service Pack 9. I use servlets and
              HttpSession together. The idea is to store shared info in the session. I
              insert complex objects, which implements Serializable interface, in the
              session and SOMETIMES when I try to extract this object casting the
              object to the real class I encounter an Exception:
              action:
              permisosPortal=(EstructuraPermisosPortal)sesion.getAttribute(portal);
              portal value is "pruebas"
              result:
              Message,
              java.lang.ClassCastException:
              com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
              Trace,
              java.lang.ClassCastException:
              com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
              at
              com.administracion.modeloGestionSeguridad.Autenticacion.permisosAdquiridos(Autenticacion.java:41)
              at
              com.administracion.novedadesServlet.FormularioAltaNovedadesServlet.service(FormularioAltaNovedadesServlet.java:47)
              at
              javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
              I don't know where is the problemm because if I introduce a
              System.out.println before this sentence it never crashes.
              action:
              System.out.println(sesion.getAttribute(portal).getClass().getName()+"
              "+sesion.getAttribute(portal));
              result:
              no crash.
              Could anyone help me?
              Thanks.
              

    Hi,
              I am work with Weblogic 5.1, Service Pack 9. I use servlets and
              HttpSession together. The idea is to store shared info in the session. I
              insert complex objects, which implements Serializable interface, in the
              session and SOMETIMES when I try to extract this object casting the
              object to the real class I encounter an Exception:
              action:
              permisosPortal=(EstructuraPermisosPortal)sesion.getAttribute(portal);
              portal value is "pruebas"
              result:
              Message,
              java.lang.ClassCastException:
              com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
              Trace,
              java.lang.ClassCastException:
              com.administracion.modeloGestionSeguridad.EstructuraPermisosPortal
              at
              com.administracion.modeloGestionSeguridad.Autenticacion.permisosAdquiridos(Autenticacion.java:41)
              at
              com.administracion.novedadesServlet.FormularioAltaNovedadesServlet.service(FormularioAltaNovedadesServlet.java:47)
              at
              javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:915)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:879)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:365)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:253)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
              I don't know where is the problemm because if I introduce a
              System.out.println before this sentence it never crashes.
              action:
              System.out.println(sesion.getAttribute(portal).getClass().getName()+"
              "+sesion.getAttribute(portal));
              result:
              no crash.
              Could anyone help me?
              Thanks.
              

Maybe you are looking for

  • Replacemen​t HP Mini 210-2006sa Keyboard in UK

    Good day all. Could someone please advise me where I can buy a new Replacemen​t HP Mini 210-2006sa Keyboard in UK. Thanks for your time. Best Regards.

  • Where to find WSDL files in CRMOD R18

    I am having trouble finding the WSDL downloads in the latest version of CRMOD (R18) In the past they were available by clicking Admin and then they were in the bottom left corner. The docs say they should be there as well: https://secure-ausomxdsa.cr

  • Is there a way to capture the position of the scrollbar?

    On this form that i am using, I am capturing where the cursor is by using temp_value := :System.Cursor_Record to find out what record it is and then when the timer expires i am asking it to go back to that captured record by GO_RECORD(temp_value ) wh

  • OMG OMG OMG PLEASE HELP!!!

    itunes won't open still!!! i really don't know what to do and im about to give up PLEASE!!! i downloaded quicktime with out itunes but it still wont open!! i really really really need help!!:( dell   Windows XP  

  • Reader 9.3.3 (Vista) : problem to launch external application

    Hello! I have a file which have links to start external application. In Adobe Reader 9.3.3 (Windows Vista), I have that dialog box (in french, sorry) : How can I activate launching external applications? Thank you for your help. François