Obtaining Session object

Is there is a way of obtaining the Session/Request object from the context in a normal class running within a servlet container?
Thanks.

For the Request object, there isn't one until a request takes place, at which time a servlet object's doGet() or doPost() method is called. If the servlet wants to call that 'normal' class then it could use a method that takes an HttpServletRequest as a parameter. Same for a session.
If you initialize that class when the container starts up, there aren't any sessions or any requests in existence, so it doesn't make sense to ask how it can access those things.

Similar Messages

  • How to obtain a session object from session id

    Hi all,
    let say that I have a list of session ids, and I want by scheduald task to check whether the session is alive\active.
    I saw that the HttpSessionContext was deprecated. (see: http://javasolution.blogspot.com/2007/08/getting-session-object-using-session-id.html)
    Is there any other way to check if the session is alive?

    Do it the other way: let the session itself notify that it is not alive anymore.
    Implement a HttpSessionListener which adds the session to list/set/map on create and removes the session from it on destroy, register it in the web.xml and run it.

  • Get session object in a class

    hi,
    is possible obtain the session object in a class method without send it from jsp as a parameter?

    you mean like this?
         public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest req,
              HttpServletResponse res)
              throws Exception {
              SessionManager sm = new SessionManager(req);
                                    ....sessionmanager class
    package com....;
    import java.util.*;
    import java.lang.reflect.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.http.*;
    import org.apache.log4j.*;
    * <code>SessionManager</code> is a wrapper for request, response and session
    * @author
    public class SessionManager {
         static Logger log = Logger.getLogger(SessionManager.class);
         ** Holds string containing the unique identifier assigned to this session
         private String sessionid;
         ** Holds HttpSession object
         private HttpSession session;
         ** Holds request object object - must be passed in by the calling application
         private HttpServletRequest request;
         ** Holds response object - any application sending a response must call
         ** session manager
         private HttpServletResponse response;
         ** Holds Servlet Context - useful if logging is reqd.
         private ServletContext context;
          * Page context.
         private PageContext pctx = null;
         ** Constructor to initialize with a request object
         public SessionManager(HttpServletRequest req) {
              request = req;
              session = req.getSession();
              sessionid = session.getId();
         ** Constructor to initialize with a pagecontext object - convenient to call from jsp's
         public SessionManager(PageContext pctx) {
              request = (HttpServletRequest) pctx.getRequest();
              response = (HttpServletResponse) pctx.getResponse();
              context = pctx.getServletContext();
              session = pctx.getSession();
              sessionid = session.getId();
              this.pctx = pctx;
         ** Constructor to initialize with request, response objects
         public SessionManager(HttpServletRequest req, HttpServletResponse resp) {
              request = req;
              response = resp;
              session = req.getSession();
              sessionid = session.getId();
         ** Constructor to initialize with request, servletcontext objects
         public SessionManager(HttpServletRequest req, ServletContext ctx) {
              request = req;
              context = ctx;
              session = req.getSession();
              sessionid = session.getId();
         ** Constructor to initialize with request, response and context objects
         public SessionManager(HttpServletRequest req, HttpServletResponse resp, ServletContext ctx) {
              request = req;
              response = resp;
              context = ctx;
              session = req.getSession();
              sessionid = session.getId();
         ** Setter and getter methods
         public void setRequest(HttpServletRequest req) {
              request = req;
              session = req.getSession();
              sessionid = session.getId();
         ** Setter and getter methods
         public void setContext(ServletContext ctx) {
              context = ctx;
         ** Setter and getter methods
         public ServletContext getContext() {
              return context;
         public void createLoginSession(java.io.Serializable obj) {
              if (obj == null)
                   log.debug("Object is null");
              setAttribute("user", obj);
         public void setAttribute(String key, java.io.Serializable obj) {
              session.setAttribute(key, obj);
         public void removeAttribute(String key) {
              session.removeAttribute(key);
         ** Setter and getter methods
         public HttpServletRequest getRequest() {
              return request;
         ** Setter and getter methods
         public HttpServletResponse getResponse() {
              return response;
         ** Checks if either member session or guest session exists
         public boolean isLoggedIn() {
              if (session.getAttribute("user") != null)
                   return true;
              else
                   return false;
         public long getCreationTime() {
              return session.getCreationTime();
         ** Setter and getter methods
         public String getId() {
              return session.getId();
         public long getLastAccessedTime() {
              return session.getLastAccessedTime();
         public int getMaxInactiveInterval() {
              return session.getMaxInactiveInterval();
         ** Setter and getter methods - also useful for retrieving state object(s)
         public Object getAttribute(String name) {
              if (session != null)
                   Object sObject = session.getAttribute(name);
                   //Log.debug("Session State for the object "+name+" is "+sObject);
                   return sObject;
              else
                   return null;
         ** Setter and getter methods - gets enum of all stored state objects
         public Enumeration getAttributeNames() {
              return session.getAttributeNames();
         public void invalidate() {
              session.invalidate();
              // Remove all object that is bound to this session
              //wip : Resetting instance variable.
              //This is necesary as further operations on session will
              //result in illegalstateexception
              session = null;
         public boolean isNew() {
              return session.isNew();
         public void setMaxInactiveInterval(int interval) {
              session.setMaxInactiveInterval(interval);
          * This method returns the host url in the form "www.carclub.com".
          * <p>
          * The return value is compatible with default_website field of clubs DB table.
          * </p>
          * @return host url present as part of the http request object
         public String getHostURL()
              if (request == null)
                   return null;//No request object present, hence return null
              String str = request.getServerName();
              //Log.debug("--- The request URL is --- " + str);
              return str;
          * Flushes <code>out</code> stream.
         public void flush()
              throws IOException
              if (pctx != null)
                   pctx.getOut().flush();
    }

  • Memory limitation for session object!

    what is the memory limitation for using session objects?
    venu

    as already mentioned there is no actual memory limitation within the specification, it only depends on the jvm's settings
    how different app-server handle memory management of session objects is another part of the puzzle, but in general you should not have problems in writting any object to the session.
    we had the requirement once to keep big objects in session, we decided to do a ResourceFactory that returns us the objects, and only store unique-Ids into the session.
    We could lateron build on this and perform special serialization tasks of big objects in the distributed environment.
    Dietmar

  • How to get Multiple Values for a key from a session object?

    Hi,
    It might seem dumb but I am facing a problem here with the session object. I'll paste the session object's content from the netbeans "Local Variables" window for clarity -
    Name Type Value
    hsession StandardSessionFacade #66
    session LWSFSession #69
    inherited
    attributes Hashtable #80
    [0] Hashtable$Entry "cart"=>#115
    key String "cart"
    value DummyCart #115
    item null
    submit null
    v Vector
    [0] String Full Metal Jacket
    [1] String As Good As It Gets
    [2] String Tim
    What I want is to get the values "Full Metal Jacket", "As Good As It Gets" and "Tim" from the session obejct?
    The problem I am facing is that if I do a session.getAttribute("cart"), I'll get a single value in return. What will that value be? Will it be "item", "submit" or "v"? And if I want all the values in v above, how can I get them?
    Thanks.

    None of the above.
    HttpSession.getAttribute() will return what you put into it using HttpSession.setAttribute(). In your case, it'll return an Object which you need to cast to DummyCart. Then you can access the data in DummyCart using the API of the DummyCart class.
    hth

  • How to get Request/Session objects in a Webdynpro application

    Hi
    I am working in Enterprise Portal 7.0.
    in one of the iViews which displays a JSP page, i have set a parameter in request and session objects.
    How can i get it in my Webdynpro ABAP Application?
    Thanks & Regards
    Abhimanyu L

    hi Abhimanyu
    I believe originally access to session was deliberately not made available inside WDA.
    Growing security concerns due to misuse of session information and
    perhaps other reasons as well.
    X.509  is considered a better approach.
    This may not help you in your problem.
    But you may see a trend in WDA pushing more robust and client independent
    approaches.
    Full x.509 access should remove the need for session fiddling.
    Also when developers access such session info directly, there is a possiblity
    when they dont understand the technology exactly that they create a security hole.
    You may know how to do safely, it is however discouraged.
    Im not aware of a way to get at the session info inside the WDA framework.
    Well not without a mod to the framework.
    It may be possible without a mod, but I dont know the trick.
    If someone has a little trick... please post.
    You may need to use BSP, if your only solution requires access to the session info.
    regards
    Phil

  • Using a session object to hold the value of a record set?

    Hi,
    I'm trying to hold the value of a record set (or literally the content of a column in a query in a db) in a session variable so that I can call on this later and insert into another table.
    I'm not sure of the correct syntax, I've already made a connection to the DB. I'm trying the following but it doesnt seem to like the code:
    <% session.setAttribute("code",rs("column_name")); %>
    <%String attrib =
    String.valueOf ( session.getAttribute("code")); %>
    Hello <%= attrib %>
    Any ideas, I dont know how to reference the record set, I declared the recordset previously as rs. Help! Can't find examples anywhere on the net!

    So just to recap. I appear to be seeing the column name "custorderno" within the Microsoft Access query "lastcust". But I get "no data found" when I run the following code (which I have sectioned off)
    <!-- connect to database and lastcust query --!>
    <%
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    Connection conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Tomcat/jakarta-tomcat-4.1.31/webapps/ROOT/Oatcake.mdb","","");
    Statement statement = conn.createStatement();
    String sql = "SELECT * FROM lastcust";
    ResultSet rs = statement.executeQuery(sql);
    while (rs.next()) {
    %>
    <TR><TD><%= rs.getString("custorderno") %></TD>
    </TR>
    <% session.setAttribute("code",rs.getString("custorderno")); %>
    <% String attrib =
    String.valueOf ( session.getAttribute("code") ); %>
    Hello <%= attrib %> [B]
    <%
    %>
    </TABLE>
    <%
    if (statement != null)
    statement.close();
    if (conn != null)
    conn.close();
    catch (Exception e) {out.print(e);}
    %>
    </BODY>
    </HTML>
    No as mentioned I am (as you can see) declaring everything as a string when in actual fact the contents of the "custorderno" within the query is set to a autonumber within MS Access.
    The while loop does work by returning the contents but the session object part is not working correctly with the following result returned:
    [B]java.sql.SQLException: No Data Found
    Help please!

  • EJB 3.0: java.io.IOException: Unable to find session object ...

    Hello,
    We have an EJB3 application deployed to an Oracle AS 10.1.3.1.0 instance.
    Our main point of entry to the application is a stateful session bean (that controls access), that has injected several other stateful session beans.
    Like this:
    +@Stateful(name = "TstreamUserSession")+
    +public class TstreamUserSessionBean extends UserSessionBean implements TstreamUserSession {+
    +@EJB(name = "ContactSession")+
    private ContactSessionLocal contactSession;
    +@EJB(name = "GuestSession")+
    private GuestSessionLocal guestSession;
    +@EJB(name = "TechCustomerSession")+
    private TechCustomerSessionLocal techCustomerSession;
    +@EJB(name = "PmSession")+
    private PmSessionLocal pmSession;
    +@EJB(name = "CustomerSession")+
    private CustomerSessionLocal customerSession;
    +@EJB(name = "PartnerSession")+
    private PartnerSessionLocal partnerSession;
    +@EJB(name = "AdminSession")+
    private AdminSessionLocal adminSession;
    +@EJB(name = "SuperAdminSession")+
    private SuperAdminSessionLocal superAdminSession;
    +@EJB(name = "VmSession")+
    private VmSessionLocal vmSession;
    +public TstreamUserSessionBean() {+
    +}+
    +...+
    In this class, we also look up these sessions, because we need several instances of these, in this manner:
    +private synchronized Object getSessionInstance(String sessionName) throws AccessDeniedException {+
              +try {+
                   InitialContext ic = new InitialContext();
                   return ic.lookup("java:comp/env/" sessionName);+
              +} catch (NamingException e) {+
              +}+
         +}+
    However, we keep getting the following messages after a certain period.
    java.io.IOException: Unable to find session object 2816103596632839360 for location 'AdminSession'
    +10/01/12 11:50:04 at com.evermind.server.ejb.EJBInternalInputStream.resolveObject(EJBInternalInputStream.java:70)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.checkResolve(ObjectInputStream.java:1346)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.activateBean(StatefulSessionEJBObject.java:581)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:213)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:159)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.processTimedOutSessions(StatefulSessionEJBHome.java:371)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.cleanUpMaintenance(StatefulSessionEJBHome.java:306)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.EJBTask.run(EJBTask.java:47)+
    +10/01/12 11:50:04 at com.evermind.util.Task.schedule(Task.java:51)+
    +10/01/12 11:50:04 at com.evermind.util.TaskManager.run(TaskManager.java:221)+
    +10/01/12 11:50:04 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)+
    +10/01/12 11:50:04 at java.lang.Thread.run(Thread.java:595)+
    I guess this occurs when the stateful session TstreamUserSession is reactivated?
    Or when the ones being injected are passivated?
    Any idea why this occurs, or how to suppress it, because it really spams our logs...
    Thanks.

    Hello,
    We have an EJB3 application deployed to an Oracle AS 10.1.3.1.0 instance.
    Our main point of entry to the application is a stateful session bean (that controls access), that has injected several other stateful session beans.
    Like this:
    +@Stateful(name = "TstreamUserSession")+
    +public class TstreamUserSessionBean extends UserSessionBean implements TstreamUserSession {+
    +@EJB(name = "ContactSession")+
    private ContactSessionLocal contactSession;
    +@EJB(name = "GuestSession")+
    private GuestSessionLocal guestSession;
    +@EJB(name = "TechCustomerSession")+
    private TechCustomerSessionLocal techCustomerSession;
    +@EJB(name = "PmSession")+
    private PmSessionLocal pmSession;
    +@EJB(name = "CustomerSession")+
    private CustomerSessionLocal customerSession;
    +@EJB(name = "PartnerSession")+
    private PartnerSessionLocal partnerSession;
    +@EJB(name = "AdminSession")+
    private AdminSessionLocal adminSession;
    +@EJB(name = "SuperAdminSession")+
    private SuperAdminSessionLocal superAdminSession;
    +@EJB(name = "VmSession")+
    private VmSessionLocal vmSession;
    +public TstreamUserSessionBean() {+
    +}+
    +...+
    In this class, we also look up these sessions, because we need several instances of these, in this manner:
    +private synchronized Object getSessionInstance(String sessionName) throws AccessDeniedException {+
              +try {+
                   InitialContext ic = new InitialContext();
                   return ic.lookup("java:comp/env/" sessionName);+
              +} catch (NamingException e) {+
              +}+
         +}+
    However, we keep getting the following messages after a certain period.
    java.io.IOException: Unable to find session object 2816103596632839360 for location 'AdminSession'
    +10/01/12 11:50:04 at com.evermind.server.ejb.EJBInternalInputStream.resolveObject(EJBInternalInputStream.java:70)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.checkResolve(ObjectInputStream.java:1346)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)+
    +10/01/12 11:50:04 at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.activateBean(StatefulSessionEJBObject.java:581)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:213)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBObject.remove_X(StatefulSessionEJBObject.java:159)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.processTimedOutSessions(StatefulSessionEJBHome.java:371)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.StatefulSessionEJBHome.cleanUpMaintenance(StatefulSessionEJBHome.java:306)+
    +10/01/12 11:50:04 at com.evermind.server.ejb.EJBTask.run(EJBTask.java:47)+
    +10/01/12 11:50:04 at com.evermind.util.Task.schedule(Task.java:51)+
    +10/01/12 11:50:04 at com.evermind.util.TaskManager.run(TaskManager.java:221)+
    +10/01/12 11:50:04 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)+
    +10/01/12 11:50:04 at java.lang.Thread.run(Thread.java:595)+
    I guess this occurs when the stateful session TstreamUserSession is reactivated?
    Or when the ones being injected are passivated?
    Any idea why this occurs, or how to suppress it, because it really spams our logs...
    Thanks.

  • I need to add the values stored in the session object into the html textbox

    Dear Sir,
    i have been trying to create an edit employee details page
    What i have done till now is as follow:
    1. Got employee id from HTML page.
    2. Compared it with the id stored in the database.
    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.
    4. Dispatched the session values to another servlet EditEmpDetails2.java
    what i need to do now
    5. Now i need to set the session values in the text field of the html form
    6. I also need to be able to edit those vales and store the edited values in the database.
    Please help me as i have tried doing it for 1 week without any clues
    i have tried to create a html page which is something like this:
    <html>
    <head>
    <title>Edit Employee Details Page</title>
    <body BGCOLOR="red" text="black">
    <h1 ><font color="black">Edit Employee Details Page</font></h1>
    <form action = "EditEmpDetails" method="Get">
    <table width="50% align="center"
    <tr><td>Employee ID: </td>
    <td><INPUT TYPE="TEXT" name="employeeid"<br></td></tr>
    <tr><td><center><input type="submit" value="submit"></center></td></tr>
    <tr><td><center><input type="reset" value="reset" ></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    design of my servlet EditEmpDetails.java
    public void EditEmpDetails1 extends HttpServlet
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    HttpSession session = request.getSession();
    String employeeid;
    String X = request.getParameter("employeeid");
    System.out.println("Employee iD:" + X);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:murphy");
    String query = "Select * from users where employeeid=?";
    PreparedStatement stat = con.prepareStatement(query);
    System.out.println(stat);
    stat.setString(1,X);
    ResultSet rs = stat.executeQuery();
    while(rs.next())
    String Z = rs.getString(password);
    if(Z.equals(X))
    String A = rs.getString(1);
    session.setAttribute("employeeid", A);
    String B = rs.getString(2);
    session.setAttribute("firstname", B);
    String C = rs.getString(3);
    session.setAttribute("lastname", C);
    String D = rs.getString(4);
    session.setAttribute("gender", D);
    String E = rs.getString(5);
    session.setAttribute("dateofbirth", E);
    String F = rs.getString(6);
    session.setAttribute("address", F);
    String G = rs.getString(7);
    session.setAttribute("postalcode", G);
    String H = rs.getString(8);
    session.setAttribute("phone", H);
    String I = rs.getString(9);
    session.setAttribute("mobile", I);
    String J = rs.getString(10);
    String url = "/EditEmpDetao;s.java";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url)
    dispatcher.forward(request,response);
    catch (Exception e)
    system.out.println(e)
    I do not know how to put the values stored in the session object into the html text box

    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.do you really need to store this in session object?
    5. Now i need to set the session values in the text field of the html form which form? in a new html/jsp page? i suggest go for a JSP
    In your JSP page use JSP expression tags to put the session attributes.
    it's something like : <input type='text' name='employeeid' value='<%= session.getAttribute("employeeid") %>' >and you need to generateanother servlet for saving the details/modifications to the database.
    I think i m clear enough.
    if you need more clarifications. just try it and then post your problem.
    Diablo

  • How to use a Session object in a Javascript function

    I have an object that I have set in my session.
    On my jsp I want to pull it out of my session and use it as a parameter for a javascript function. But I am not sure how to do that... the function call is below... I want to assign a value to ifFormat (last variable in function) But I am not sure what to use inside javascript.
    <script type="text/javascript">
         Calendar.setup({inputField:"f_date_dfFirstPmtDate",
                                              button:"f_trigger_dfFirstPmtDate",
                                             singleClick:true,
                                              ifFormat:XXXXX});
    </script>

    Note that javascript runs on the client side, and JSP runs on the server. JSP and the session objects are NOT available to javascript in reaction to the user.
    If this function is called only when the page is first created, not when the user interacts with the page, or if you want that value to be constant with respect to the javascript, then you can do this:
    <%
      String someValue = (String)session.getAttribute("theAttributeName");
    %>
    <script type="text/javascript">
         Calendar.setup({inputField:"f_date_dfFirstPmtDate",
                                              button:"f_trigger_dfFirstPmtDate",
                                             singleClick:true,
                                              ifFormat:<%=someVale%>});
    </script>

  • Applet throws "Unable to obtain Document object"

    Hello,
    I have an applet in a html-page and a link to show the applet (in a later version this should be a menu with links to different applets).
    If I click very often (click,click,click,click) on the link I get an exception (see below).
    Used environment:
    - Windows 2000 English
    - Internet Explorer 6
    - Java(TM) Plug-in: Version 1.4.2, Using JRE version 1.4.2 Java HotSpot(TM) Client VM
    Here are my 4 tiny source-codes:
    1. My test Applet:
       import java.util.*;
       import javax.swing.*;
       public class BigApplet extends JApplet {
          Vector vec = new Vector();
          public void init() {
             this.getContentPane().add(new JLabel("BigApplet"));
             for (int i = 0; i < 10; i++) {
                vec.add(new Object[250000]);
       }And 3 HTML-Pages:
    2. Frame.html
       <html>
          <frameset cols="80,*" frameborder="NO" border="0" framespacing="0">
             <frame src="link.html" name="menuFrame" noresize marginheight="0" marginwidth="0">
             <frame name="applet" noresize marginheight="0" marginwidth="0">
          </frameset>
       </html>3. Link.html
       <html>
          <a href="applet.html" target="applet">Applet</a>
       </html>4. Applet.html
       <applet code="BigApplet.class" codebase="bin" />The three html pages are in the same directory and the BigApplet.class is in the bin-folder of this directory.
    If I start the frame.html from Explorer and than click very fast (about 5 to 10 times) on the link to the applet I get this exception:
    netscape.javascript.JSException: Unable to obtain Document object
         at sun.plugin.AppletViewer.getDocumentBase(Unknown Source)
         at sun.plugin.AppletViewer.getCodeBase(Unknown Source)
         at sun.plugin.AppletViewer.appletInit(Unknown Source)
         at sun.plugin.viewer.LifeCycleManager.initAppletPanel(Unknown Source)
         at sun.plugin.viewer.IExplorerPluginObject$Initer.run(Unknown Source)If the applet is delivered by a webserver (tried IIS and Apache) the Internet Explorer crashes without a message. In that case I get a different exception (found in the log file of the java console):
    java.lang.NullPointerException
         at sun.plugin.util.URLUtil.canonicalize(Unknown Source)
         at sun.plugin.AppletViewer.getDocumentBase(Unknown Source)
         at sun.plugin.AppletViewer.getCodeBase(Unknown Source)
         at sun.plugin.AppletViewer.appletInit(Unknown Source)
         at sun.plugin.viewer.LifeCycleManager.initAppletPanel(Unknown Source)
         at sun.plugin.viewer.IExplorerPluginObject$Initer.run(Unknown Source)Any idee what to do to be sure that an user can not produce this error?
    Bye
    Thomas

    Hello, I am getting the same error under different circumstances. No clicking is involved. What I need to know is what causes the error? Anyone know?
    And levi_h - the end users of applets often get impatient when they don't see immediate results and will click and click and click and click, thinking that somehow they are helping the situation. You may feel they deserve to be punished, but the powers that be who are the customers who will deploy our applets don't feel that way at all, and they are the ones that pay our salaries and allow us to be sheltered, clothed, fed and send our kids to college!

  • How to use session object in jsp

    hi all
    marry christmas
    can anyone plz tell me how to use session obect in jsp
    rachna
    Message was edited by:
    rachna_arora82

    hi rachna,
    JSP has a default(implicit) session object...... use the getSession(true) method on the session object and then going u can either get or set attributes depending on the requirement
    That was in general and now with the issue u have got..... what u can do is that the u can create session for every user who logs in and when he/she tries to login again then u can probably check for the existing session object in the JSP and perform the logic as required..... any clarifications plzzzzzzz let me know
    Thanks n Regards
    Naveen M
    Message was edited by:
    Novice_inJAVA
    Message was edited by:
    Novice_inJAVA

  • How to implement a Session Object.

    Hi,
    If anybody show me any example of how to implement
    session object so that I can store any parameters such as user id and use it later on. And also if there is any good web site for reference about using session object.
    thanks

    You can use the the session.setAttribute and session.getAttribute methods.
    For example let's say you would want to store a username in the session after a user has logged on:
    String usrname = request.getParameter("username");
    session.setAttribute("myStoredUsername", usrname);
    you can then retrieve it using the get method. Remember that the entities stored inside a session object are generic objects and need to be cast to be used:
    String usrname2 = (String)session.getAttribute("username");
    Hope this helps
    Chelman

  • How to validate a session object in jsp?

    Hi All,
    i am facing a problem.The problem is how to validate the session object object in jsp.I have written a java script by using a defined function as setInterval and has given 5 mintues if the user is idle and will show a pop up menu before time out the session but in case of page active still this pop up menu is coming. The java script as follows.
    function SetTimer(){
         //How long before timeout (should be a few minutes before your server's timeout
         //set timer to call function to confirm update
         if(timeoutMinutes)
         timerObj = setInterval("ConfirmUpdate()",60000);
    function clearTimerFn(){
              timerCount = 0;
              clearInterval(timerObj);
              //timerObj = setInterval("ConfirmUpdate()",60000);
    function ConfirmUpdate(){
         //Ask them to extend
         if(confirm("Your session is about to expire. Press 'OK' to renew your session.")){
              //load server side page if ok
              var url = "ajaxSessionchecker.do?sessionvalidate=sessionvalid";
              LoadXMLDoc(url);
    And in jsp i am calling this js function as
    <%session=request.getSession(false);
              if(session.getLastAccessedTime()==60000){ %>
              <script type="text/JavaScript">
         clearTimerFn();
    </script>
    <%}else{
    session.setMaxInactiveInterval(-1000);} %>
    could you pls help me out?

    The reason for doing this is when ever i come to this user.jsp from account.jsp with a different account number this user.jsp is not refreshed and i still
    see the same old user.jsp for the previous account that i naviated before. Also please let me know if there is any other approach to acheive this taskDoes refreshing the page by pushing F5 solve the problem?
    If so, then the browser is caching the page, despite your attempts to stop it.

  • How can i get the value stored in the session object using its sessionid

    how can i get the value stored in the session object using its sessionid by running stand alone java application

    myforum wrote:
    how can i get the value stored in the session object using its sessionid by running stand alone java applicationThis does not seem to make sense! You need at least to give a lot more detail of what you are doing.

Maybe you are looking for

  • Visual Studio 2013 WP Emulator not working after adding more RAM

    After a few days I installed VS 2013 on my laptop which had 3GB RAM and got notified by visual studio that I need at least 4 GB for hardware virtualization. Now I have 6GB RAM and Hyper-V restarted and VS still doesn't recognize my new RAM and doesn'

  • Transfer master data from a project from one client to another client

    Hi all, I have a training client and a production client.  The project master data has been created (Tcode CJ01) in training client with multiple levels and WBS.  Is there a way to transfer the master data from the training client to another client s

  • Is my Photoshop CS6 legal?

    Is my Photoshop CS6 legal?  Under "Help"; "Product Registration", "Deactivate" and "Updates" are grayed out. I have a legal CD & serial# (& Adobe receipt/packing list).  When someone else reinstalled Windows7 on 12-04-12, CS6 was reinstalled.  Since

  • Mountain Lion - random kernel panic

    Hi folks, My Mountain Lion upgrade has resulted in random kernel panics. I've unistalled all apps that have been cited as potential problems and also tried reinstallign Mountain Lion from both the recovery partition and by redownloading from App Stor

  • Problem with desktop icons

    Hi, Hope someone can help, my desktop icons have turned into these wierd square buttons with a grey background - The icons are no longer draggable but simply work as buttons. Basically everything that I dump on the desktop turns into one these grey s