Session data in a class

Hi,
i have project with jsp pages and java classes. I register some session attributes
in a jsp like this
if (login == null)
login = new Login();
session.setAttribute("login",login);
Now, for some functionallity, i need this info in a class. Is there anyway i can get this info
from the session and do this:
Login login = (Login)session.getAttribute("login");
Thanks

It depends how your utility classes are written.
By and large, though, if your separate classes need some data (be it session-based or not) you need to provide it to them either at construction or in the method parameters.
You should try not to write your business classes from the perspective of a particular platform - do your business objects really care that the user interface is web-based (ie, uses a session) or do they only care that a Login instance is passed to them at some point?

Similar Messages

  • Unable to create/cleanup persistent session data cache

    Hi all
    After the iPlanet Webserver 4.1 SP12 starts up the following entries appears in the error log file:
    [14/Oct/2003:09:24:48] info ( 5999): successful server startup
    [14/Oct/2003:09:24:48] info ( 5999): iPlanet-WebServer-Enterprise/4.1SP12 BB1-12/18/2002 14:18
    14/Oct/2003:09:24:49] catastrophe ( 5999): Unable to create/cleanup persistent session data cache
    What does the last entry mean?
    Thanks for any help :-}
    Best regards,
    Jean-Claude

    Check permissions, disk space of following dirs:
    server_root/https-instance/ClassCache/
    server_root/https-instance/SessionData/
    Try to:
    Clear Session Data
    Delete JSP Class Cache Files
    using the Session Data link under Admin Server GUI Java tab
    Hope it helps!

  • How do I access session data through an EJB?

    Hi
    How do I access session data through an EJB?
    I am currantly developing a Web service (using ejb's, JBoss.net and Apache Axis). A client making a call to this Web service, is expecting a bussiness-object in return. My problem is that this bussiness-object i stored in a users session data. How do I retrieve this bussiness-object from the users session.
    I have read that this does not work with httpsessions, is this true? If this is true, is it possible to store the bussiness object in a JavaBean e.g:
    <jsp:useBean id="userContextWebImpl" scope="session" class="com.ac.march.client.UserContextWebImpl">
    <%
    String key = "test";
    String value = "This is the value";
    userContextWebImpl.setValue( key, value1 );
    %>
    </jsp:useBean>
    and then retrieve this information through the EJB? Or is it possible to do this by using Statfull JavaBeans? Or can this be done through a nother solution?
    Please help!

    I have created a JavaBean with scope="application" to store some data. The data is stored when a user prefomes a spesific task.
    A different person then makes a call to a Web-Service on the server. The Web-Service then asks an EJB to retrieve the data stored in the JavaBean (servlet cotext). In other words: How do I retrieve this data from the EJB?
    I have tried with this code, but with no luck.
    (ApplicationContextWebImpl is the JavaBean)
    public static String getBookingResult( String key )
         String myResult = null;
         String myKey = key;
         ApplicationContextWebImpl applicationContextWebImpl = null;
         try
              applicationContextWebImpl = new ApplicationContextWebImpl();
              myResult = (String)applicationContextWebImpl.getValue( key );
         catch ( java.rmi.RemoteException e )
         return myResult;
    }

  • How can we reset the session data in SAP ISA B2B application.

    com.sap.isa.isacore.action.IsaCoreInitAction$StartupParameter this action class providing the special feature to store all data passed to it in the request as parameters into the session context and make them available for all other actions.
    1. But in the inner class they had defined private parametrized constructor.
    2. Action class is defined as final.(there is no chance to override the method)
    3. There is no setter method (only getter() is available).
    4. Creating a new Z_ class that is reflecting in entire application.
    5.They had hard coded the Session attribute name in Action class.
    6. Application is expecting a session object with the same attributes.
    Is there any chance to create a new object for this class or any where any chance to reset the session data. Am using the Multiple_SoldTO concept in my application. My back end ECC .Please help me.
    Advanced Thanks
    PC.M
    Edited by: pmudigonda on Jul 6, 2011 1:21 PM

    I am not sure about your requirement, but yet.. Did you check UserSessionData object? It encompasses all the session variables.

  • Could not deserialize session data, java.io.InvalidClassException

    Whenever I click on logout link from Liferay(Which deployed as application on Weblogic 10.3),It shows below Exception in the console however i am able to logout sucessfully.
    Could not deserialize session data.
    java.io.InvalidClassException: org.hibernate.proxy.pojo.javassist.SerializableProxy; local class incompatible: stream classdesc serialVersionUID = 1180036893511205383, local class serialVersionUID = -2265249369383210104 at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:560)
    It seems to be Classpath polluted with different hibernate jars.But still not able to figure it out.Below is the jar files which i have in classpath.
    hibernate-annotations.jar
    hibernate-commons-annotations.jar
    hibernate-core.jar
    hibernate3.jar
    Application Server: Weblogic 10.3
    Any Help would be much appreciated.

    Sounds like you have two different versions of a class in the two applications.
              If you change a class implementation and recompile - the updated class gets a new UID. Looks like maybe one app has a jar with the older class and the other app has a jar with the new class.

  • Verify whether the session data is kept in the Coherence caches

    I have successfully combined the MapViewer application with WebLogic and Oracle Coherence*Web.
    How to verify whether the session data of MapViewer application is kept in the Coherence caches or not?
    All out put show that both of MapViewer and WebLogic server as well as Coherence are running well.
    All the following steps are right?
    The procedure is as the following:
    1. Create a WebLogic domain: Map_domain.
    2. Start the WebLogic domain Map_domain by running startWebLogic.sh script.
    3. Install Coherence.jar as a library on WebLogic.
    4. Copy the coherence.jar in the WAR's WEB-INF/lib directory.
    5. Create a reference to the shared library by modifying the weblogic.xml in web applications WEB-INF directory
    and add the following contents:
    <weblogic-web-app>
         <library-ref>
              <library-name>coherence-web-spi</library-name>
              <specification-version>1.0.0.0</specification-version>
              <implementation-version>1.0.0.0</implementation-version>
              <exact-match>false</exact-match>
         </library-ref>
    <weblogic-web-app>6. Install Coherence-web-spi.war as a WebLogic library.
    7. Install the MapViewer as a WebLogic application.
    8. Start a Coherence cache server using the cmd file web-cache-server.cmd and then start MapViewer application.
    The content of web-cache-server.cmd file:
    @echo off
    @rem This will start a cache server
    setlocal
    :config
    @rem specify the Coherence installation directory
    set coherence_home=F:\coherence
    @rem specify the JVM heap size
    set memory=256m
    :start
    if not exist "%coherence_home%\lib\coherence.jar" goto instructions
    if "%java_home%"=="" (set java_exec=java) else (set java_exec=%java_home%\bin\java)
    :launch
    set java_opts="-Xms%memory% -Xmx%memory%"
    "%java_exec%" -server -showversion "%java_opts%" -cp %coherence_home%\lib\coherence.jar;
    %coherence_home%\lib\coherence-web-spi.war
    -Dtangosol.coherence.management.remote=true
    -Dtangosol.coherence.cacheconfig=WEB-INF/classes/session-cache-config.xml
    -Dtangosol.coherence.session.localstorage=true
    com.tangosol.net.DefaultCacheServer %1
    goto exit
    :instructions
    echo Usage:
    echo   ^<coherence_home^>\bin\cache-server.cmd
    goto exit
    :exit
    endlocal
    @echo onEdited by: jetq on Jan 13, 2010 9:32 AM

    Any opinions are welcome.

  • Use of error page resulting in could not deserialize session data exception

              We have recently converted classes that store objects in the HTTP Session to implement
              serializable.
              Our application uses an error page set up in our web.xml for 500 errors.
              It also uses filters.
              When our application throws an exception and allows the server to handle it
              via the error page setup, we end up with the exception we threw, plus a number
              of
              "Could not deserialize session data" exceptions in the stack trace.
              In general, the exceptions can be traced to lines in code that attempt to reference
              one of our "serializable" session objects to get user info for logging purposes.
              Problem is, other applications that do not use error pages to handle exceptions
              do not throw these types of exceptions in the wl-domain.log and they use the same
              classes.
              Does anyone know why this happens when using error pages and what we need to do
              to correct it?
              We are using Weblogic 8.1sp2.
              Thanks!!
              Example of the stack trace messages:
              ####<May 5, 2004 2:52:17 PM EDT> <Error> <HTTP Session> <machinexyz> <cgServer>
              <ExecuteThread: '11' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <BEA-100028>
              <Could not deserialize session data.
              java.io.NotSerializableException: weblogic.servlet.internal.FilterConfigImpl
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
                   at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
                   at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
                   at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                   at weblogic.servlet.internal.AttributeWrapper.convertObjectToBytes(AttributeWrapper.java:136)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:112)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:69)
                   at weblogic.servlet.internal.session.SessionData.getAttribute(SessionData.java:431)
                   at doh.stuff.OurFilter.doFilter(OurFilter.java:67)
                   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
                   at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:305)
                   at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:523)
                   at weblogic.servlet.internal.WebAppServletContext.handleException(WebAppServletContext.java:3908)
                   at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3683)
                   at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
              >
              ####<May 5, 2004 2:52:17 PM EDT> <Error> <HTTP Session> <machinexyz> <cgServer>
              <ExecuteThread: '11' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <BEA-100028>
              <Could not deserialize session data.
              java.io.NotSerializableException: java.util.Vector$1
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
                   at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
                   at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
                   at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                   at weblogic.servlet.internal.AttributeWrapper.convertObjectToBytes(AttributeWrapper.java:136)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:112)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:69)
                   at weblogic.servlet.internal.session.SessionData.getAttribute(SessionData.java:431)
                   at doh.stuff.OurHTML.<init>(OurHTML.java:57)
                   at doh.stuff.OurFilter.startLog4j(OurFilter.java:513)
                   at doh.stuff.OurFilter.doFilter(OurFilter.java:75)
                   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
                   at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:305)
                   at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:523)
                   at weblogic.servlet.internal.WebAppServletContext.handleException(WebAppServletContext.java:3908)
                   at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3683)
                   at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
              >
              

              We have recently converted classes that store objects in the HTTP Session to implement
              serializable.
              Our application uses an error page set up in our web.xml for 500 errors.
              It also uses filters.
              When our application throws an exception and allows the server to handle it
              via the error page setup, we end up with the exception we threw, plus a number
              of
              "Could not deserialize session data" exceptions in the stack trace.
              In general, the exceptions can be traced to lines in code that attempt to reference
              one of our "serializable" session objects to get user info for logging purposes.
              Problem is, other applications that do not use error pages to handle exceptions
              do not throw these types of exceptions in the wl-domain.log and they use the same
              classes.
              Does anyone know why this happens when using error pages and what we need to do
              to correct it?
              We are using Weblogic 8.1sp2.
              Thanks!!
              Example of the stack trace messages:
              ####<May 5, 2004 2:52:17 PM EDT> <Error> <HTTP Session> <machinexyz> <cgServer>
              <ExecuteThread: '11' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <BEA-100028>
              <Could not deserialize session data.
              java.io.NotSerializableException: weblogic.servlet.internal.FilterConfigImpl
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
                   at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
                   at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
                   at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                   at weblogic.servlet.internal.AttributeWrapper.convertObjectToBytes(AttributeWrapper.java:136)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:112)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:69)
                   at weblogic.servlet.internal.session.SessionData.getAttribute(SessionData.java:431)
                   at doh.stuff.OurFilter.doFilter(OurFilter.java:67)
                   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
                   at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:305)
                   at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:523)
                   at weblogic.servlet.internal.WebAppServletContext.handleException(WebAppServletContext.java:3908)
                   at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3683)
                   at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
              >
              ####<May 5, 2004 2:52:17 PM EDT> <Error> <HTTP Session> <machinexyz> <cgServer>
              <ExecuteThread: '11' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <BEA-100028>
              <Could not deserialize session data.
              java.io.NotSerializableException: java.util.Vector$1
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
                   at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
                   at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
                   at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
                   at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
                   at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
                   at weblogic.servlet.internal.AttributeWrapper.convertObjectToBytes(AttributeWrapper.java:136)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:112)
                   at weblogic.servlet.internal.AttributeWrapper.getObject(AttributeWrapper.java:69)
                   at weblogic.servlet.internal.session.SessionData.getAttribute(SessionData.java:431)
                   at doh.stuff.OurHTML.<init>(OurHTML.java:57)
                   at doh.stuff.OurFilter.startLog4j(OurFilter.java:513)
                   at doh.stuff.OurFilter.doFilter(OurFilter.java:75)
                   at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
                   at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:305)
                   at weblogic.servlet.internal.ServletResponseImpl.sendError(ServletResponseImpl.java:523)
                   at weblogic.servlet.internal.WebAppServletContext.handleException(WebAppServletContext.java:3908)
                   at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3683)
                   at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
              >
              

  • Tomcat 5.0.25 persisting session data by default ?!?

    This is, I imagine, a dumb question, but I can't quite figure out what is happening by looking at past postings.
    When I start Tomcat I get an error : "IOException while loading persisted sessions" because some classes we use are not serializable. That makes sense - we didn't design them to be serialized.
    I understand that Tomcat CAN try to persist session data across restarts. However, I do not want it to do this. I thought this was something we had to configure, but it looks like it happens by default (?)
    Anyway ... any advice about how to prevent this behavior, at least for our app, would be appreciated ... really puzzled ... !
    Thanks in advance for any help you can give !!
    ethan

    Well, thanks ... I have been there actually, but it only tells me how to set up the 'Experimental" Persistent Manager and not how to turn this off. Here is an interesting blurb from that site :
    <<<<<
    Whenver Catalina is shut down normally and restarted, or when an application reload is triggered, the standard Manager implementation will attempt to serialize all currently active sessions to a disk file located via the pathname attribute. All such saved sessions will then be deserialized and activated (assuming they have not expired in the mean time) when the application reload is completed.
    In order to successfully restore the state of session attributes, all such attributes MUST implement the java.io.Serializable interface. You MAY cause the Manager to enforce this restriction by including the <distributable> element in your web application deployment descriptor (/WEB-INF/web.xml).
    >>>>>>>
    I THINK this means that persitence is on by default. I'm not certain because - if that is true - then what is the Persisistent Manager for ? I have found thi ssnippet of config in conf/server.xml :
    <<<<<<
    <Context path="/myApp" reloadable="true" docBase="myApp" workDir="C:\myApp\\work\org\apache\jsp" >
    <Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>
    </Context>
    >>>>>>
    which tells Tomcat to use the Persistent Manager for my app and then ... tells it not to store session data. And this seems to work ... at least the error messages go away. Now, though, I get a new and different error message :
    <<<<<<
    SEVERE: no store configured, persistence disabled
    >>>>>>
    So I am still doing something wrong ... I think ... and still looking for help ... B-)
    Thanks again, black_lotus ... maybe we'll learn about this together ;-)

  • Save the session data in the database !

    Hello everybody,
    I read an article on JavaWorld website about saving the session data of an application in the database instead of mantaing them in memory.
    In this way, the web application is more scalable and in case the application server crashed the session data can be taken by another application server.
    I was sure that this was a good motivation of writing a class to save the session data of my application in the database, but i read another article where a good methodology to
    create a scalable web application was to save the session data in more application server so if one application server crashed another application server can take the control of the entire application.
    I think that at the moment i have just a bit of confusion in my mind.
    Any suggestion ?
    Cheers.
    Stefano

    What you've read was a method of "load balancing" where "state" is maintained by a backend server instead of the web servers themselves. Yes, if done properly, this would achive true web server independance, and if one crashed, another would pick up where it left off. Of course, you'll still need an HTTP load balancer in front of the web server farm, so it can dynamically shift the load.
    From an architecture standpoint, it's a good way to go, but only IF you really need 7x24 with zero downtime. Reason being twofold. 1) It's a huge performance hit, becase each GET/POST requires a trip to the DB, because it's holding state. 2) It's a lot of work, because you're now taking on the role of "managing" sessions (e.g. when to expire, reading the cookie/URL for session IDs.
    I was once responsible for a 7x24 Intranet that ran core business applications. My service level agreement with my customers was 7x24 alright, but with the risk of a possible "blip" (meaning, if one server crashed, simply reconnect and continue your work). Worst case, one lost just that one page worth of work.
    I hope that helps explain!
    bRi

  • How to save Session Data using Oracle?

    Hi
    I am creating a web application that will be running on an infrastructure which will utilise a number of web servers, web gardens and a load balancer.
    As the application is using Sessions, and that our application is using Oracle as the database, we would like to use the database to save the Session data. However, I am struggling to find any good examples on how to do this with Oracle.
    I note that Oracle provides the following class: Oracle.Web.SessionState.OracleSessionStateStore, but I am unsure what I need to do in the Code Behind and what if any tables do I need to create in the database.
    Can anyone help me, please?

    You can store Oracle session state in the Oracle DB or in the mid-tier with Oracle Coherence.
    Here's a link to the Oracle ASP.NET provider doc:
    http://download.oracle.com/docs/cd/E17666_01/doc/win.112/e17192/toc.htm
    Chapter 1 has instructions about setting up the DB store ASP.NET provider data and schema objects.

  • Showing session data on new servlet

    I am writing a java servlet and trying to bring session information to another servlet screen in order to edit the data. When I bring up the fields on the screen the session data does not show. Here is a copy of the java program.
    public void doPost( HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    HttpSession session = req.getSession(true);
    if(session == null)
    System.out.println(" No record found.");
    else
    String memberID = (String)session.getAttribute("memberID");
    System.out.println("Record found in modify. " + memberID);
    out.println("<jsp:useBean ID=\"memberID\" CLASS=\"Member\"/>");
    out.println("<jsp:SetProperty NAME=\"setMemberID\"PROPERTY=\"memberID\" />");
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Member Modify</title>");
    out.println("</head>");
    out.println("<body ONLOAD=\"dynAnimation()\">");
    out.println("<p ALIGN=\"center\" STYLE=\"border: 4px ridge #FFFF00; \">");
    out.println("<font SIZE=\"5\" FACE=\"BookmanITC Lt BT\">MEMBER MODIFY</font></p>");
    out.println("<form METHOD=\"POST\" ACTION=\"http://localhost:8080/servlet/PetShop.membermodify\" " +
    "ONSUBMIT=\"location.href='_derived/nortbots.htm';return false;\" NAME=\"FrontPage_Form1\" " +
    "WEBBOT-onSubmit=\"return FrontPage_Form1_Validator(this)\">");
    out.println(" <p ALIGN=\"center\"> </p>");
    out.println(" <p> </p>");
    out.println(" <p ALIGN=\"left\"> " +
    " & nbsp; Member ID: " +
    " <input TYPE=\"text\" NAME=\"memberID\" value='<%=req.getParameter (\"setMemberID\")%>'" +
    "SIZE=\"20\" MAXLENGTH=\"20\" TABINDEX=\"1\" />");
    I've also tried:
    value="<%=setMemberID%>"
    But I either get no data or the expression I put in. I also did a system.out.println to see if the session data is there and it is.

    String memberID =
    (String)session.getAttribute("memberID");
    System.out.println("Record found in modify. " +
    memberID);
    value='<%=req.getParameter (\"setMemberID\")%>'"
    I've also tried:
    value="<%=setMemberID%>"
    But I either get no data or the expression I put in.try memberID instead of setMemberID
    (as in value="<%= memberID %>" or request.getParameter("memberID") )

  • Save Session Data

    Hi to all,
    is there a way to save Session Data in  a Bsp application (similar to Php $_SESSION array)?
    or i have to use shared object/export-import memory id  to save temp data in a session (example: Shopping Cart)?
    thanks
    Alessandro

    Hello,
    you can use a statefull bsp with an application class...
    The objects in the class have a lifetime over the whole session.
    regards

  • Retrieving session data in JSP  which is forwarded from a servlet

    I'm trying to retrieve session data which is set in a servlet and pass to a jsp. But its returning NULL . The session IDs are equal.
    Scenario:
    JSP display the checkbox, user selects it and submits to a servlet. the servlet display the selected items and stores the data in session.
    when the user press back button in servlet all i want to do is display those checked box which were selected before as checked in the JSP so that user can edit.
    Following is a small test code
    JSP
    <html>
         <head>
              <title>Item List</title>
         </head>
         <body bgcolor="#fedeab"><br><br><br>
         <p align=center>
              <font size=4>
              Choose the item you want!!!
         </p>
         <form action="/demo/showitem" method="post">
              <%=session.getId()%>
              <div align=center>
              <fieldset style="width:250px">
              <legend style="text-align:center">List of item</legend> <br>
              <%     
                   if (session.getAttribute("book1")!=null) {
              %>
                   <input type="checkbox" name="book1" value="book1" checked > Book 1 <br>
              <% } else {%>
                   <input type="checkbox" name="book1" value="book1" > Book 1 <br>
              <% }%>
              <input type="submit" value="Enter">
              </fieldset>
              </div>
         </form>
         </body>
    </html>               
    Servlet
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ShowItem extends HttpServlet
         public void doPost (HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException
              HttpSession session = req.getSession(true);
              res.setContentType("text/html");
              PrintWriter out = res.getWriter();
              out.println(session.getId());
              out.println("<br>");
              out.println("<form>");
              String book1 = req.getParameter("book1");
              session.setAttribute("book1",book1);
              if (book1 != null)
                   out.println ("1." + book1 +"<br>");
                   out.println("<br><br><input type=\"submit\" name=\"buy\" value=\"Buy\">");
              else
                   out.println("No item to display<br>");
              out.println("&nbsp&nbsp<input type=\"submit\" name=\"back\" value=\"Back\">");
              out.println("</form>");
              RequestDispatcher page = getServletContext().getRequestDispatcher("/jsp/litemlist.jsp");
              if ((req.getParameter("buy"))!= null)
                        page.forward(req, res);
              if ((req.getParameter("back"))!= null)
                        page.forward(req, res);
         public void doGet (HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException
              doPost(req,res);
    }

    req.getParameter("book1") is not NULL and returning the value of the checkbox "book1". The problem occurs when the back button is press and try to retrieve the session value in the JSP. At that time, session.getAttribute("book1") returns NULL.
    But if i convert the servlet to JSP then everything is working fine.
    So i wanted to know if there is anything wrong in the way i store the session value in the servlet and forwarding to the JSP.
    Thanks

  • Servlet Session data being shared

    I have a bunch of servlets tha basically generate reports. The problem I'm having is that when two users run the same servlet at about the same time, one of the reports will be over written by the data of the other report. It almost seems that the users are sharing the same context.
    Is there any way to fix this or do you have ny suggestions, tips as to how to prevent this.
    Thnaks in advance for any help you may provide.

    I ran into a similar problem not to long ago with sessions. I had an instance or global reference to the session object in my servlet. When two or more people used the servlet at just the right time I would get problems where data was getting used across sessions. For example:
    public class FooServlet extends HttpServlet
         HttpSession session;
         doGet(HttpServletRequest req, HttpServletResponse res)
              session = req.getSession(false);
              doStuffWithSessionData();
         doStuffWithSessionData()
              String temp = session.getValue("temp");
              //do some stuff
    }So, person A would connect to the servlet, and their session would be retreived, and the instance reference would get set to their session. Person B would connect at about the same time, their session would get retreived and the instance reference would get set to theirs... right before the getValue("temp") on person A's session is called. So, whatever I was doing for person A would end up using the data out of person B's session. I like to call this a race condition.
    It is important to keep in mind that servlets are accessed by multiple threads concurrently, so you need to make sure your servlets are thread safe. Instance variables that get modified with each request are a very bad, non-thread safe thing and will cause odd behaviour like what you are describing. I speak from experience.
    I fixed the above by removing the instance reference and doing the following:
    public class FooServlet extends HttpServlet
         doGet(HttpServletRequest req, HttpServletResponse res)
                   doStuffWithSessionData(req);
         doStuffWithSessionData(HttpServletRequest req)
              HttpSession session = req.getSession(false);
              String temp = session.getValue("temp");
              //do some stuff
              //NOTE: this works most of the time. However, if the client
              //connects with more than one browser window using the same
              //session, I could run into some trouble here too.
    }That was a quick fix. However, what I really need to do is create a separate class to encapsulate all user session data and access the session and all data through public static synchronized methods on that class, passing it the request object when I do it. That way all data is stored in one object, and that object is used to do all session access in a thread-safe, synchronized manner.
    I hope this information helps you and is understandable. If you have any questions I will try to clarify. Making things thread-safe can be a daunting task.

  • Error loading serialized session data

    Could anyone please suggest how to fix this issue. We run 2 Solaris servers
              running WL5.1 SP8:
              Thank you!
              Fri Jan 12 16:23:43 PST 2001:<E> <HttpSessionContext> Error loading
              serialized session data for session
              OlzPsQ2ZCGETxLZsvwig2hgGGyZEU4opBHfSaq1P02MlsbGKNK64QcKLS3JTa0QJZyZxdjVIY5k3
              |5212765075526534138/-1062730671/6/80/80/7002/7002/80/-1
              java.io.InvalidClassException:
              weblogic.servlet.internal.session.SessionData; Local class not compatible:
              stream classdesc serialVersionUID=2475912102520200080 local class
              serialVersionUID=8380332519449050139
              at java.lang.Throwable.fillInStackTrace(Native Method)
              at java.lang.Throwable.fillInStackTrace(Compiled Code)
              at java.lang.Throwable.<init>(Compiled Code)
              at java.lang.Exception.<init>(Compiled Code)
              at java.io.IOException.<init>(Compiled Code)
              at
              java.io.ObjectStreamException.<init>(ObjectStreamException.java:29)
              at
              java.io.InvalidClassException.<init>(InvalidClassException.java:47)
              at java.io.ObjectStreamClass.validateLocalClass(Compiled Code)
              at java.io.ObjectStreamClass.setClass(Compiled Code)
              at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.inputObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at
              weblogic.servlet.internal.session.FileSessionContext.loadSession(FileSession
              Context.java:467)
              at
              weblogic.servlet.internal.session.FileSessionContext.invalidateSession(FileS
              essionContext.java:391)
              at
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.invalida
              teSessions(Compiled Code)
              at
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.trigger(
              SessionContext.java:479)
              at
              weblogic.time.common.internal.ScheduledTrigger.executeLocally(Compiled Code)
              at weblogic.time.common.internal.ScheduledTrigger.execute(Compiled
              Code)
              at weblogic.time.server.ScheduledTrigger.execute(Compiled Code)
              at weblogic.kernel.ExecuteThread.run(Compiled Code)
              java.io.InvalidClassException:
              weblogic.servlet.internal.session.SessionData; Local class not compatible:
              stream classdesc serialVersionUID=2475912102520200080 local class
              serialVersionUID=8380332519449050139
              at java.lang.Throwable.fillInStackTrace(Native Method)
              at java.lang.Throwable.fillInStackTrace(Compiled Code)
              at java.lang.Throwable.<init>(Compiled Code)
              at java.lang.Exception.<init>(Compiled Code)
              at java.io.IOException.<init>(Compiled Code)
              at
              java.io.ObjectStreamException.<init>(ObjectStreamException.java:29)
              at
              java.io.InvalidClassException.<init>(InvalidClassException.java:47)
              at java.io.ObjectStreamClass.validateLocalClass(Compiled Code)
              at java.io.ObjectStreamClass.setClass(Compiled Code)
              at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.inputObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at java.io.ObjectInputStream.readObject(Compiled Code)
              at
              weblogic.servlet.internal.session.FileSessionContext.loadSession(FileSession
              Context.java:467)
              at
              weblogic.servlet.internal.session.FileSessionContext.invalidateSession(FileS
              essionContext.java:391)
              at
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.invalida
              teSessions(Compiled Code)
              at
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.trigger(
              SessionContext.java:479)
              at
              weblogic.time.common.internal.ScheduledTrigger.executeLocally(Compiled Code)
              at weblogic.time.common.internal.ScheduledTrigger.execute(Compiled
              Code)
              at weblogic.time.server.ScheduledTrigger.execute(Compiled Code)
              at weblogic.kernel.ExecuteThread.run(Compiled Code)
              

    It might cause by inconsistent service patch and/or versions among your
              servers in your cluster. Double check the installation, especially
              classpathes of all your servers. Make sure you apply SP8 correctly in all
              servers.
              Cheers - Wei
              "Andre Taube" <[email protected]> wrote in message
              news:[email protected]...
              > Could anyone please suggest how to fix this issue. We run 2 Solaris
              servers
              > running WL5.1 SP8:
              >
              > Thank you!
              >
              >
              > Fri Jan 12 16:23:43 PST 2001:<E> <HttpSessionContext> Error loading
              > serialized session data for session
              >
              OlzPsQ2ZCGETxLZsvwig2hgGGyZEU4opBHfSaq1P02MlsbGKNK64QcKLS3JTa0QJZyZxdjVIY5k3
              > |5212765075526534138/-1062730671/6/80/80/7002/7002/80/-1
              > java.io.InvalidClassException:
              > weblogic.servlet.internal.session.SessionData; Local class not compatible:
              > stream classdesc serialVersionUID=2475912102520200080 local class
              > serialVersionUID=8380332519449050139
              > at java.lang.Throwable.fillInStackTrace(Native Method)
              > at java.lang.Throwable.fillInStackTrace(Compiled Code)
              > at java.lang.Throwable.<init>(Compiled Code)
              > at java.lang.Exception.<init>(Compiled Code)
              > at java.io.IOException.<init>(Compiled Code)
              > at
              > java.io.ObjectStreamException.<init>(ObjectStreamException.java:29)
              > at
              > java.io.InvalidClassException.<init>(InvalidClassException.java:47)
              > at java.io.ObjectStreamClass.validateLocalClass(Compiled Code)
              > at java.io.ObjectStreamClass.setClass(Compiled Code)
              > at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.inputObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at
              >
              weblogic.servlet.internal.session.FileSessionContext.loadSession(FileSession
              > Context.java:467)
              > at
              >
              weblogic.servlet.internal.session.FileSessionContext.invalidateSession(FileS
              > essionContext.java:391)
              > at
              >
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.invalida
              > teSessions(Compiled Code)
              > at
              >
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.trigger(
              > SessionContext.java:479)
              > at
              > weblogic.time.common.internal.ScheduledTrigger.executeLocally(Compiled
              Code)
              > at weblogic.time.common.internal.ScheduledTrigger.execute(Compiled
              > Code)
              > at weblogic.time.server.ScheduledTrigger.execute(Compiled Code)
              > at weblogic.kernel.ExecuteThread.run(Compiled Code)
              >
              > java.io.InvalidClassException:
              > weblogic.servlet.internal.session.SessionData; Local class not compatible:
              > stream classdesc serialVersionUID=2475912102520200080 local class
              > serialVersionUID=8380332519449050139
              > at java.lang.Throwable.fillInStackTrace(Native Method)
              > at java.lang.Throwable.fillInStackTrace(Compiled Code)
              > at java.lang.Throwable.<init>(Compiled Code)
              > at java.lang.Exception.<init>(Compiled Code)
              > at java.io.IOException.<init>(Compiled Code)
              > at
              > java.io.ObjectStreamException.<init>(ObjectStreamException.java:29)
              > at
              > java.io.InvalidClassException.<init>(InvalidClassException.java:47)
              > at java.io.ObjectStreamClass.validateLocalClass(Compiled Code)
              > at java.io.ObjectStreamClass.setClass(Compiled Code)
              > at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.inputClassDescriptor(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.inputObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at java.io.ObjectInputStream.readObject(Compiled Code)
              > at
              >
              weblogic.servlet.internal.session.FileSessionContext.loadSession(FileSession
              > Context.java:467)
              > at
              >
              weblogic.servlet.internal.session.FileSessionContext.invalidateSession(FileS
              > essionContext.java:391)
              > at
              >
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.invalida
              > teSessions(Compiled Code)
              > at
              >
              weblogic.servlet.internal.session.SessionContext$SessionInvalidator.trigger(
              > SessionContext.java:479)
              > at
              > weblogic.time.common.internal.ScheduledTrigger.executeLocally(Compiled
              Code)
              > at weblogic.time.common.internal.ScheduledTrigger.execute(Compiled
              > Code)
              > at weblogic.time.server.ScheduledTrigger.execute(Compiled Code)
              > at weblogic.kernel.ExecuteThread.run(Compiled Code)
              >
              >
              

Maybe you are looking for

  • Using Active Directory (LDAP Plugin) Across Multiple AD Servers

    Hi, I need to give an existing application the ability to talk to multiple active directories using the AD LDAP interface from a J2EE Applcation running on Apache 2.x/Tomcat 5.x (there are 4 independent AD trees and users from ANY of the trees can ac

  • Any BAPI or FM to post a parked PO invoice

    Hi Can any one let me know any BAPI to use to post a parked invoice.(Invoice created with reference to Purchase Order) with regards, Sumanth

  • Can I use DAQcard-50​0 with Xp pro and LV5.1.1

    Hi I am running Xp pro, with labview 5.1.1 and I do not seem to be able to get a driver for my DAQcard-500. Can anyone tell me if this is even possible, and if so how do i install it? because i can not get the system to recognise the DAQcard-500 Chee

  • Updating TOP table in Time Evaluation

    Hello All, I need to  write a pcr which updates TIP entry (Total Number of hours) and pass it to TOP table. What I want to do is using ROUNDHR operation I have to round 'total number of hours' field of TIP and then pass those hours to TOP table so th

  • Airport netgear connection

    Hi, Today I have purchased an airport express to connect my slingbox wirelessly to my home network, I have tried to connect the airport which is upstairs to my netgear router downstairs I thought that this would work, however it isn't and I can't see