Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Unhappy Sending Response From ServletContextListener

    Hey Guys I am using a ServletContextListener in my web application. I am able to create listener but the problem is i am not able recieve any request nor able to send any response from listener to any other servlet or browser.
    Can anyone please help me out
    Thanx in advance

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    the servlet [initial] context listener is invoked when the container stars up and shuts down the application, you can't get to it from a servlet such as during handling a request, and the context listener cannot interact with servlets.

    session listeners are similar,though you do have the http session handle there, so could set up session attributes in the listener when session is created and the down stream execution of a servlet could extract that attribute.

    but not entirely sure what it is you are wanting to do.

  3. #3
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    Hi Travishein,
    Thanks for ur precious response.
    Actually my requirement is to create a reminder. A user will set the date and time and i want to popup the window at that perticular date and time.
    So i was trying to start the thread using ServletContextListner which is going to check the date and time,but since listner cannot interact with servlets i am unable to do the above.
    Do you have any other idea for my requirement.
    Thanks In Advance

  4. #4
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    5

    Default

    i guess to have a reminder popped up automatically, such as if the page is loaded already and the user is not clicking anything, this will need to be some kind of ajax based invocation of a server side resource to "check for notifications", where if there is a notification, one is rendered (probably through some kind of dhtml or javascript then).

    I would say to start off, have a server side component , like in the servlet that renders the page, like an include, check the (thing that knows if there is a reminder to be displayed), and if so, to stuff the reminder in, such as render it out into the output html if this is a JSP page.

    Like, getting the mechanism of displaying the reminders to the user by the simple invoke the request and the response shows the reminder if any , is a good start.. Then work on the figuring out how to make this invoked asychronously using an ajax framework.

    if you aren't using one yet, the yahoo user interface (YUI) javascript library is pretty well documented and has examples for typical use. then you would need to make a server side reminder servlet that services requests for checking for reminders for a given user.

  5. #5
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. response.setContentType
    By bbq in forum Java Servlet
    Replies: 3
    Last Post: 01-17-2012, 05:37 PM
  2. Try catch response
    By Reiyn in forum New To Java
    Replies: 1
    Last Post: 03-30-2009, 08:30 PM
  3. response.sendRedirect(url)
    By mutuah in forum Advanced Java
    Replies: 2
    Last Post: 08-07-2007, 01:56 PM
  4. Velocity / XML response
    By sabatier in forum XML
    Replies: 0
    Last Post: 07-24-2007, 01:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •