Send message to client before session invalidated

i am using jsp and java servlet tech. for my web application.
my problem is :
i want to send a message to client before session invalidated.
please help me to find the best way to solve my problem.

You can detect session termination by putting an object in the session attributes which implements HttpSessionBindingListener. What you can't do is send a message to a client, basically because all http transactions are initiated by the client. The only way I can see you could do this is to put an applet on your web pages which periodically consults the server concerning the session state.
Then the problem is that there's no obvious way of determining if the session is about to timeout, only whether it has or not. Your applet couldn't return the session cookie (as such) because that would reset the session timeout and the session would never expire. If you could obtain the session without reseting the expiry (perhaps from SessionContext though that's depracated) you could look at getLastAccessedTime() and getMaxInactiveInterval, but I don't know that this can be done. You can't even count, on some systems, on the session remaining in memory.
If you really need to do this you may need to consider implementing sessions for yourself. I've done this for non-webapp based logins and it's not too hard.

Similar Messages

  • Sending message across clients

    Hello,
    wanted to know how to send message across clients. Suppose I have 2 XI servers : one is XI other is PI. I want to send message from PI to XI. how will we configure this scenario? what adapters will be used and what is the message flow ?
    Thank you.

    Hi,
    Check my thread it may be helpful
    XI adapter
    Regards,
    Prakash

  • How to send message to MessageDrivenBean from Session bean in JDeveloper

    HI I am trying to write a sample program using JDeveloper.
    I am trying to do these steps
    1) client class which gets Session bean and calls its method.
    2) write Stateless Session bean with a method which gets MDB and sends message.
    3) write Message Driven Bean ( which prints message recieved from Session bean )
    Set up
    =======
    jms.xml
    {JDevHome}\jdev\system9.0.5.2.1618\oc4j-config\jms.xml : changed jms.xml file and included
         <topic name="Demo Topic" location="jms/theTopic">
              <description>A dummy topic</description>
         </topic>
         <topic-connection-factory name="Demo Topic Connection Factory" location="jms/theTopicConnectionFactory">
              <description>A dummy topic connection factory</description>
         </topic-connection-factory>
    orion-ejb-jar.xml:
    edited MDB entry to
    <message-driven-deployment name="MessageLogger"
    destination-location="jms/theTopic" connection-factory-location="jms/theTopicConnectionFactory">
    </message-driven-deployment>
    Implementation
    ===============
    In client class:
    I am getting session bean like
    Properties props = System.getProperties();
    props.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY , "com.evermind.server.rmi.RMIInitialContextFactory");
    props.put( javax.naming.Context.SECURITY_PRINCIPAL , "admin" );
    props.put( javax.naming.Context.SECURITY_CREDENTIALS,"welcome");
    props.put( javax.naming.Context.PROVIDER_URL ,"ormi://localhost:23891/current-workspace-app");
    Context ctx = new InitialContext(props);
    MySessionHome home = (MySessionHome)
              javax.rmi.PortableRemoteObject.narrow(obj, MySessionHome.class);
    This part works fine, and I am calling method on session bean created out of home.
    In Session bean:
    I want to get TopicConnectionFactory and tried these two ways:
    a)
    getting the context by setting new environemnt values like
    Properties props = System.getProperties();
    props.put( javax.naming.Context.INITIAL_CONTEXT_FACTORY , "com.evermind.server.jms.EvermindConnectionFactory");
    props.put( javax.naming.Context.SECURITY_PRINCIPAL , "admin" );
    props.put( javax.naming.Context.SECURITY_CREDENTIALS,"welcome");
    props.put( javax.naming.Context.PROVIDER_URL ,"ormi://localhost:9227/current-workspace-app");
    Context ctx = new InitialContext( props);
    When I try this,it is complaining that it cannot instantiate EvermindConnectionFactory.
    I am not sure which factory class we have to use here.i tried all the Factory class in that package.but didn't worked.
    next I used,
    b)
    tried to use default context in session bean to get MDB factory
    String TOPIC_NAME="jms/theTopic";
    String TOPIC_CONNECTION_FACTORY="jms/theTopicConnectionFactory";
    TopicConnectionFactory connectionFactory = (TopicConnectionFactory)new InitialContext().lookup("java:comp/env/" + TOPIC_CONNECTION_FACTORY);
    this gives
    04/06/13 23:46:09 javax.naming.NameNotFoundException: jms/theTopicConnectionFactory not found in MySession
    04/06/13 23:46:09      at com.oracle.naming.J2EEContext.getSubContext(J2EEContext.java:93)
    this may be because JMS server runs on different port than other EJBs and have different namespaces.
    Can any body give info,how we can make use of Message Driven bean from a Session Bean or from a JSP page or from a simple class inside JDeveloper.
    Thanks in advance.
    gopal

    Hi,
    There are some hints in this forum for how to do this.
    I put together and make it working.
    This example creates an MD Bean and have a simple message and a client class send messages to that bean.
    Steps
    =====
    1)
    a)in {JDev Home}\jdev\system9.0.5.2.1618\oc4j-config\jms.xml
         <topic name="Demo Topic" location="jms/demoTopic">
              <description>A dummy topic</description>
         </topic>
         <topic-connection-factory name="Demo Topic Connection Factory" location="jms/theTopicConnectionFactory">
              <description>A dummy topic connection factory</description>
         </topic-connection-factory>
    b) in current project in orion-ejb-jar.xml
    go to orion-ejb-jar properties and add these values there to MDB node
    destination-location=jms/demoTopic
    connection-factory-location=jms/theTopicConnectionFactory
    2) create a dummy session bean and a dummy client for that session bean
    This sets default configuration for the client application we write
    doing so we do not need to set properties to get Initial context.It makes use of
    {JDev Home}\jdev\system9.0.5.2.1618\oc4j-config\.client\jndi.properties
    We can directly get Contexxt ctx = new InitialContext();
    3) Create MDB and put this sample code in method
    onMessage()
    TextMessage tm = (TextMessage) msg;
    try {
    String text = tm.getText();
    System.err.println("Received new message : " + text);
    catch(JMSException e) {
    e.printStackTrace();
    4) go to properties for the MDB and set Destination to Topic
    5) write Client code
    Context ctx =new InitialContext();
    // 1: Lookup ConnectionFactory via JNDI
    TopicConnectionFactory factory =     
    (TopicConnectionFactory) ctx.lookup("jms/theTopicConnectionFactory");
    // 2: Use ConnectionFactory to create JMS connection
    TopicConnection connection = factory.createTopicConnection();
    // 3: Use Connection to create session
    TopicSession session = connection.createTopicSession( false, Session.AUTO_ACKNOWLEDGE);
    // 4: Lookup Desintation (topic) via JNDI
    Topic topic = (Topic) ctx.lookup("jms/demoTopic");
    // 5: Create a Message Producer
    TopicPublisher publisher = session.createPublisher(topic);
    // 6: Create a text message, and publish it
    TextMessage msg = session.createTextMessage();
    msg.setText("This is a test message from My Test Client!!! .");
    publisher.publish(msg);
    6) Run the server and run the client

  • Sending messages between clients

    hi,
    I want to make small instant messenger,like yahoo.I have made a server which accept connection from different client & send online user list to each and every client connected to the server.
    But now i have to send messages between the clients(chatting).
    This can be do either through server or allow server establishing connection betwwen two client & allow them to continue chatting session.But i am not able to figure out how i do either of the things using socket programming.
    Please help me ,to establish chatting session between the clients.
    Thank you for replies
    alok

    Yes, It should be Non public to Other client but not to server.
    Suppose client1 want to send message to client2 then it send message to server,then server passes this message to client2.
    Now as client2 got the it send some reply to client1 which
    is also reach to client1 through server.But I have problem ,as how
    does client2 knows to which client he has send message as no of clients are connected to the server & more then one client has send message to client2.
    Basically I have problem in sending reply to a message send by the different client connected to the server.
    Thank You for reply

  • Send message from client problem

    Hi all,
    i want send some JMS messages from standalone client program to MDB through OC4J JMS service. I wrote little sample client program:
         public static void main(String [] args)
              throws Exception
              Hashtable env = new Hashtable();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
              env.put(Context.SECURITY_PRINCIPAL, "admin");
              env.put(Context.SECURITY_CREDENTIALS, "admin");
              env.put(Context.PROVIDER_URL, "ormi://localhost:23791/");
              Context context = new InitialContext(env);
              QueueConnectionFactory connectionFactory = (QueueConnectionFactory)context.lookup("jms/my/test.queueConnectionFactory");
              QueueConnection connection = connectionFactory.createQueueConnection();
              QueueSession qSession = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
              Queue q = (Queue)context.lookup("jms/my/test.queue");
              QueueSender sender = qSession.createSender(q);
              connection.start();
              TextMessage message = qSession.createTextMessage();
              message.setText("Text messaga no.: "+i);
              sender.send(message);
              sender.close();
              qSession.close();
              connection.close();
    But it throws JMSException:
    javax.jms.JMSException: Unable to connect to JMSServer (/127.0.0.1:9127)
         at com.evermind.server.jms.EvermindQueueConnection.connect(EvermindQueueConnection.java:144)
         at com.evermind.server.jms.EvermindQueueConnection.send(EvermindQueueConnection.java:94)
         at com.evermind.server.jms.EvermindQueueSession.send(EvermindQueueSession.java:117)
         at com.evermind.server.jms.EvermindQueueSender.send(EvermindQueueSender.java:75)
         at com.evermind.server.jms.EvermindQueueSender.send(EvermindQueueSender.java:36)
         at com.evermind.server.jms.EvermindQueueSender.send(EvermindQueueSender.java:31)
         at SenderClient.main(SenderClient.java:35)
    Row 35 is sender.send(message);
    And running standalone OC4J (9.0.3) throws exception too:
    java.lang.NullPointerException
         at com.evermind.server.jms.JMSServer.removeClient(JMSServer.java:724)
         at com.evermind.server.jms.JMSRequestHandler.run(JMSRequestHandler.java:278)
         at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:66)
    All jms.xml stuff is configured properly.
    Can someone help me what i do wrong?
    Best regards
    Radovan Sninsky

    Hi radovan,
    Check your jdk versions at your server and client. Make sure that your are running your server and client with the same jre. Even i had the same problem when oc4j was started with jdk1.4 jre and running the client using jdk1.3.
    Hope this helps
    shrini

  • How to send message to Client about Server shutdown.

    I have made a Chatting Application using RMI.
    I need to send messages to all the Clients when a Server shutdowns abnormally.
    One way is that I use shutdown hook on the Server Application.
    But, what if the power of the machine on which server is running goes off. How will the Client get to know that server is down.
    I also want that If a Client shutdowns abnormally,it should send the message to the Server which in turn will send message to other Clients about the particular Client.
    Thanks & Regards.
    Nimesh

    Before you make any call form client to server check that sever is available. This is easily done by intorudciing an rmi method that will return true e.g m_sever.isAvalable(); if server is availbel you will get ture if not then you will get an RMI Excpetion which you then trap and attemp to reconnect to the server (NAming.lookup() ) .. if several attempts fail then assume server is down.
    When a client dies it throws an excpetion on the sErver :
    java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:116)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
         at java.io.FilterInputStream.read(FilterInputStream.java:66)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:442)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:536)
    trap this and deal with it appropriatly.
    hope this helps.
    Charbel.

  • How to send message to client?

    Hello, I'm newbie in J2EE. I have a client (e.g. GUI class) which have to "connect" to EJB and start further processing when others 3 clients also connect to this EJB. It's not a problem to obtain reference to EJB and connect to it, but I don't know how to send some message from EJB to client.
    I've tried to implement it with events, but it not works. Is it possible to use event for this? Are there any patterns to solve this class of problems? Please, help!
    Below fragments of my code for events:
    GamesListFrame.java
          try
             title.setText("text");
             tablesManager = getHome().create();
             tablesManager.addStartGameListener(this);
             tablesManager.generateEvent();
          } catch ...
    }and TablesManagerBean.java
        * @ejb.interface-method
        *     view-type="remote"
       public void generateEvent()
          EventQueue q = Toolkit.getDefaultToolkit().getSystemEventQueue();
          StartGameEvent event = new StartGameEvent(this);
          q.postEvent(event);     
        * @ejb.interface-method
        *     view-type="remote"
       public void addStartGameListener(StartGameListener listener)
          listenerList.add(StartGameListener.class, listener);
       public void processEvent(AWTEvent event)
          if (event instanceof StartGameEvent)
             EventListener[] listeners = listenerList.getListeners(StartGameListener.class);
             for (int i=0; i<listeners.length; i++)
                ((StartGameListener)listeners).GameStarted((StartGameEvent)event);
    else
    super.processEvent(event);

    Before you make any call form client to server check that sever is available. This is easily done by intorudciing an rmi method that will return true e.g m_sever.isAvalable(); if server is availbel you will get ture if not then you will get an RMI Excpetion which you then trap and attemp to reconnect to the server (NAming.lookup() ) .. if several attempts fail then assume server is down.
    When a client dies it throws an excpetion on the sErver :
    java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:116)
         at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
         at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
         at java.io.FilterInputStream.read(FilterInputStream.java:66)
         at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:442)
         at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
         at java.lang.Thread.run(Thread.java:536)
    trap this and deal with it appropriatly.
    hope this helps.
    Charbel.

  • How to send message from Message Driven Bean  to JMS client?

    In my project I have JMS client, two QueueConnectionFactory and Message Driven Bean. Client send message to MDB through the first QueueConnectionFactory , in one's turn MDB send message to client through the second Queue Connection Factory . I already config my Sun AppServer for sending message in one way, and sending message from MDB to the second QueueConnectionFactory. But on my Client there is an error : �JNDI lookup failed: javax.naming.NameNotFoundException: No object bound to name java:comp/env/jms/MyQueue2� (jms/MyQueue2 � this is the name of my Queue). So it couldn't get this message.
    P.S.
    Thank you for help!!!

    What is the name of the second queue?is the connection factory on the local?Yes the connection factory is on the local. The name of my first queue is jms/MYQueue and the name of another one is jms/MyQueue2.

  • See all room and send message

    hello, first sorry for my english.
    i' m developing a multyplayer games whith multi-rooms
    application.onAppStart = function(){
    application.player_so = SharedObject.get("player_so",
    false);
    application.nextId = 0;
    application.onConnect = function(newClient,name){
    application.nextId++
    newClient.id = application.nextId
    application.player_so.setPrope rty(newClient.name, name);
    application.acceptConnection(newClient);
    newClient.sendMessage = function(testo) { ;
    for(var c=0; c<application.clients.length;c++) { ; ;
    application.clients[c].call("sendMessage", null,"hello i'm:
    "+name);
    ok.. i have 10 rooms .. then the client
    var client_nc:NetConnection= new NetConnection();
    client_nc.connect("rtmp:/myapplication/room1","ciao");
    // i create 10 room
    client_nc.onStatus = function(info) {
    client_nc.sendMessage = function(msg) {
    dbg_txt.text +="Debug: "+ msg+"\n";
    dbg_txt.scroll += 1;
    dbg_txt.scroll = dbg_txt.maxscroll;
    mybutton.onRelease= function(){
    _root.client_nc.call("sendMessage", null,
    _root.testo_txt.text );
    how can i send a message for all client?
    if i send a message this message is received only clients of
    a determinate room, i want send message for client of all
    room

    As I said the problem is in delta pull mechanism. Talk to your Basis or EP guy and check the following link
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/eb/101fa0a53244deb955f6f91929e400/content.htm
    Regards, IA

  • JMS send message

    Hello,
    in my message bean i have method with 3 BigDecimal parameters.
    How can i send message from client with 3 BigDecimal parameters?
    thanks for help.

    No, but you can. use an object stream to serialize the message and you are
              all set.
              _sjz.
              "deezh" <[email protected]> wrote in message
              news:3d23fdbf$[email protected]..
              >
              >
              

  • Send XML to client: message box

    Hi,
    In a BPM workflow I'm putting together, I need to open a message box for information
    (title, message, OK button). In the documentation, I found that I should send
    an XML document to a client that looks like this:
    <message-box title="title" style="information" options="ok">
    <actionid>"1013679664318"</actionid>
    </message-box>
    Which I did: I added a "Send XML to client" action in the "True" part of a decision
    node with a message-box element and its attributes, and actionid as a nested element.
    When I trigger the workflow, it goes through all the expected steps but the window
    does not pop up at all. I could not find the reason why anywhere. So has anyone
    experienced the same problem ? If yes, how did you solve it ?
    Cheers,
    Yann

    Hi Sudhar.
    I don't think your workflow will execute the next node before you mark the current
    node as done. Conseqently setting the done in the decision box isn't possible.
    Giora
    "Sudhar" <[email protected]> wrote:
    >
    After I do the Send XML to Client from the exeucte tab of an action...instead
    of
    marking the task as done on the call back actions...i try to mark the
    same task
    as done in the next task after a decision box....it doesnt seem to work?
    any ideas? should you always mark a task as done on the same task?

  • Have you a simple client for send message on oc4j 9.0.2.0.0 ?

    Hi to All!
    Have you a simple client to send message on a queue in OC4J 9.0.2 ?
    Can you show me how is possible to write the config file to connect to oc4j application server?
    thanks very much
    Andrea

    I added -Xcheck:jni and -Xcheck:nabounds to the command line and got this one now :
    500 Internal Server Error
    Error parsing JSP page /westflo-fsweb/main/header.jsp
    Error creating jsp-page instance: java.lang.ClassFormatError: __jspPage8_main_header_jsp (Method "pushBody" has illegal signature "()Ljavax/servonInfo.classjavax/servlet/j")
    My whole command line is :
    /usr/java130_wei/bin/java -ms128m -mx256m -Xcheck:jni -Xcheck:nabounds -Xnoclassgc -verbosegc -Duser.dir=/usr/oc4j/j2ee/home -Denvironment=DEV2GMSFS -Dwestflo.dir=/website/DEV2/GMSFS/oc4j_instance2/westflo/westflo/ -Ddeployment.dir=/website/DEV2/GMSFS/oc4j_instance2/pie/gms/ -Demissionrc.dir=/website/DEV2/GMSFS/oc4j_instance2/emissionrc/emissionrc-web/ -jar /usr/oc4j/j2ee/home/oc4j.jar -out /website/DEV2/GMSFS/oc4j_instance2/oc4j_config/log/server.log -err /website/DEV2/GMSFS/oc4j_instance2/oc4j_config/log/oc4j.err -config /website/DEV2/GMSFS/oc4j_instance2/oc4j_config/config/server.xml

  • Send message from java not client

    I have a java app running on my server and I'd like to send
    messages to subscribed clients. All the messaging examples I find
    have the messages originating from a flex producer. I want java to
    be the producer.

    I used this example to get it done.
    http://western-skies.blogspot.com/2006/07/flex-sending-messages-from-server-side.html

  • Send Message to Session via SQL?

    Hello,
    I see some of the oracle tools touting the ability to send lan messages to oracle sessions/users.
    Can anyone describe how to do this with SQL? I've looked and looked and cannot find a solution to this.
    Thanks!

    Ah so it looks like this is not a function of sql/oracle db but application ie Oracle Enterprise Manager.
    To send a message to a currently connected user
    Expand a server group, and then expand a server.
    Expand Management, and then expand Current Activity.
    Click Process Info.
    The current server activity is displayed in the details pane.
    In the details pane, right-click a Process ID, and then click Send Message.
    Note It is not possible to send a message to a user when SQL Server Enterprise Manager is running on Microsoft® Windows® 98.
    In the Message box, type the message.
    Optionally, select Using hostname, and enter the computer name to send the message to a specific computer.
    I don't know how i would do that because there is only one host name with multiple terminal sessions. :/

  • Mail doesn't send e-mail. Before yesterday everything was ok, but now it says that a copy of the message has been sent to "Sending messages" because the contents of the message cannot be send to server. What to do? IMAP should be ok.

    Mail doesn't send e-mail. Before yesterday everything was ok, but now it says that a copy of the message has been added to "sending messages and the content of the message cannot be sent to the server". All the data in IMAP is ok. What to do?

    thanks for replying!
    When sending from one mac email account to another email account on the mac it seems to send fine, and it moves to the sent items, but nothing appears in the mac inbox.
    When sending from a mac account to the pc, it seems to send fine, and it moves to the sent items, but nothing appear in the PC inbox.
    When sending a massage from the PC to my mac email, it send fine from the PC and arrives in the inbox on the mac.
    mac to mac - seems to send but dosent arrive
    mac to pc - seems to send but doesnt arrive
    pc to mac - seems to send and arrives.
    As i said it was all working fine yesterday and for four years previous to that, but now it has just stopped.
    I hope you can help.

Maybe you are looking for

  • ALV Toolbar related Query

    Hi, When using FM 'REUSE_ALV_GRID_DISPLAY' Exporting Parameters : I_CALLBACK_PF_STATUS_SET  in SET PF Status Creating additional Buttons. In ALV Report output addition  additional buttons are coming but Standard ALV Toolbar are missing like Sort Asse

  • Clean install and time machine

    I'd like to reformat my hard drive and do a clean install of leopard. I've backed up my drive with time machine and I'm wondering if it is possible to recover all my third party applications etc etc including passwords and settings without having to

  • Change  of Plant in sales order line item

    Hi folks,      Can someone guide me how to change the line item sales order --plant after saving. it is coming as grayed once entered. Regards Srshkumar

  • My ipodtouch keeps cutting off

    Ipod is constantly cutting off during use, I tried a restore and it seems to be doing the same thing.  Has anyone experienced this or knows of a solution?

  • Flashing monitor light.....back light inverter?

    The Apple 20 inch monitor connected to my recently acquired Power PC G4 has recently started to do a series of two short and one long blinks. From researching, it would seem to be the beginnings of the backlight inverter going....but the light in the