How do I close a connection when the session ends?
I have a website that is using JavaMail to display a user's mail through the browser. I'd like to keep the connection to the mail server open during the whole session that the user is logged in, in order to improve response time. The problem is, I can't detect if a user closes their browser so that I can close the connection to the server.
Is there a way for me to close the mail server connection when the session ends?
Thanks.
Create session listener, Impliment sessionDestryoyed
method with your connection close statements.I was wondering how to use the listener for a Servlet as well, what would you type in that method to close the connection?.
public class ServletListener
implements
ServletContextListener,
ServletContextAttributeListener,
HttpSessionListener,
HttpSessionAttributeListener
public void sessionDestroyed(HttpSessionEvent arg0)
//System.out.println( arg0 );
}
Similar Messages
-
How does c:url tag know when the session is cookieless and thus to redirect
i have been looking at the source code for c:url tag and can't figure out how they are doing that. I need a way to do that in a jsp, to check if the cookies are allowed or not.
how does c:url tag know when the session is cookieless and thus to redirecthuh?
What do cookies have to do with redirecting?
Cookies get encoded into a URL using the method in HttpServletResponse: response.encodeURL() or encodeRedirectURL().
That method determines whether or not it prints out the session id as part of the url, or it gets uses cookies.
You can try: request.isRequestedSessionIdFromCookie().
If that is true, you know that session cookies are supported (or at least that one was) -
How can I close a tab when the close button is not highlighted?
I don't know how to close a tab without the x in the upper corner. The support page stated I should right click on the tab for the close button but it is not highlighted in my drop down menu.
What happens if you type or paste <b>about:config</b> in the location bar?
-
My ipod went to the ''connect to itunes mode'' and i want to use my itunes backup but how can i do that. also when the ''recover your ipod screen'' appeared i accidentally chose not to show it anymore. please help i just had it for half a day.
See Here > http://support.apple.com/kb/HT1808
You may need to try this More than Once... Be sure to Follow ALL the Steps...
Take your time... Pay particular attention to Steps 3 and 4.
Some users have reported as many as 8 or 9 attempts were necessary before success.
If the issue persists...
Then a Visit to an Apple Store or AASP (Authorized Apple Service Provider) is the Next Step...
Be sure to make an appointment first... -
I'm having a problem with the application Dropbox and I want to uninstall it. In finder it does not allow me to move it to trash telling me the dopbox application is open. How do I close it? when it shows up nowhere as an open application?
Is there a DropBox icon up in the menubar you can click on & see quit DropBox?
https://www.dropbox.com/help/41 -
How do I close a JInternalFrame when using subclasses and a separate cla...
The heading should be: How do I close a JInternalFrame when using subclasses and a separate class for the actionListener?
I have just created a JInternalFrame appclication and now I want to structure up my code. I have a Superclass that contains the usual settings for the two JInternalFrame:s, and the two subclasses with frame specific information. Both the JInternalFrames use the same OK button. I want to have the actionListener outside the classes to avoid repetition of code. But the dispose()-function does not work properly, it does not close the opened JInternalFrame. What�s wrong?
class Superclass extends JFrame
JButton b= new JButton("ok");
Superclass()
class Subclass1 extends Superclass
Subclass1 ()
add(ok);
ok.addActionListener(new Listener());
class Subclass2 extends Superclass
Subclass2 ()
add(ok);
ok.addActionListener(new Listener());
class Listener extends Superclass implements ActionListener
public void actionPerformed(ActionEvent e)
dispose();
}How do I controll in the Listener class that the button in Subclass1 is beeing pressed?First of all I think I misunderstood your question. You said you had two internal frames, so I thought you wanted to close the internal frame.
It now looks to me like you want to close the entire JFrame, which makes the code even a little easier. Something like:
JComponent component = (JComponent)event.getSource();
JFrame frame = (JFrame)SwingUtilities.windowForComponent( component );
frame.dispose();
Ok, I will make a try:
public static Container getAncestorOfClass(Class c, Component comp)
w.getAncestorOfClass(w, this); Fiirst you need to learn the basics of reading the API.
"getAncestorOfClass()" is a static method. That means you don't use a variable to invoke the method. You use the class itself.
"w" is a variable, which is a JFrame, but that is not what the first parameter should be. The first parameter is a "Class".
"this" will refer to your Listener class, but you need the Component that generated the ActionEvent.
When I thought you wanted to close an internal frame then the code would have been something like:
JComponent component = (JComponent)event.getSource();
Container container = SwingUtilities.getAncesterOfClass( JInternalFrame.class, component );
JInternalFrame internalFrame = (JInternalFrame)container;
internalFrame.invokeSomeMethodHere();If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
http://homepage1.nifty.com/algafield/sscce.html -
How do I close an app when it is playing ie. a Podcast
How do I close an app when it is playing ie a podcast?
I really do not understand what you mean. You can pause the Podcast and then go to another app. you can also go to the other app and then double click the Home button. Then touch and hold the podcast app/Music app and tap the circled minus sign to stop the podcast. You can also just double click the Home button and go to the music controls and tap pause.
-
How can I close a category in the form central form without closing it as error?
How can I close a category in the form central form without closing it as error?
I'm still not sure I follow - let me see if this is right. You want to have users signing up for something using a FormsCentral form and then when something is full you'd like that section to show as "Closed" or full so nobody else can sign up for that particular event/day/time? If that is the goal FormsCentral does not have any logic to close certain portions of the form.
Thanks,
Josh -
i got problem when trying to call my iphone 4 using facetime with my Macbook Pro 13',it did ringing,but my iphone 4 did not receive that call as if nothing happen.But,when the call ended,that call appeared in the missed call list.fyi both are connected to internet.Help!! thank you in advance
i got problem when trying to call my iphone 4 using facetime with my Macbook Pro 13',it did ringing,but my iphone 4 did not receive that call as if nothing happen.But,when the call ended,that call appeared in the missed call list.fyi both are connected to internet.Help!! thank you in advance
-
How do i fix my ipod when the screen cracks
how do i fix my ipod when the screen cracks
Have Apple, a third-party place or fix it yur self.
Apple - Support - iPod - Repair pricing
iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens
DigiExpress.us - The iPad Repair Professionals
iPod Touch Glass Replacement -
How can I retrieve my password when the retrials email was not recoverable either? I also can't use or pass the othere means of recovery? Not being able to pass or answer the security questions?
I created a new ID but never being able to update the iTunes that were purchased/saved using the old id?
I can't also delete.Hi Kazmania89,
Welcome to the Support Communities!
If you require additional assistance with this, click on the link below for guidance:
Apple ID: Contacting Apple for help with Apple ID account security
http://support.apple.com/kb/HT5699
Once you are able to gain access to the old Apple ID, this article may be helpful:
Using your Apple ID for Apple services
http://support.apple.com/kb/HT4895
I have purchased music, apps, or books with multiple Apple IDs. How can I get all of this content onto my iOS device?
First, you need to copy all of your purchased content so it is on the same Mac or PC with iTunes. This computer should be the one you sync your device with. For more information on how to move your content, see these articles:
Mac: iTunes for Mac: How to copy purchases between computers
PC: iTunes for Windows: How to copy purchases between computers
Next, authorize your computer to play content with each Apple ID in iTunes. Once your computer is authorized for all your content, it can be synced to your iPhone, iPad, or iPod touch.
Cheers,
- Judy -
On I-Mac, how can I close all tabs at the same time?
On I-Mac, how can I close all tabs at the same time?
I use Mozilla Firefox for internet.Not an Apple product, have you visited:
https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-qu ickly -
How can i fix a clip when the video and audio are not matching up?
How can i fix a clip when the video and audio are not matching up? I imported the video from a junkdrive in a .VOB format and concerted to a .mov the videos were filmed on a miniDVD recorder.
I would try detaching the audio and the dragging the audio to the left or right until it lines up.
-
How to access my hard drive when the system does not work
how to access my hard drive when the system does not work
Startup - Gray, Blue or White screen at boot, w/spinner/progress bar
Startup Issues - Resolve
Startup Issues - Resolve (2) -
how can you download premier pro when the iucon doesent exist in cloud???
In order to download the software, your computer must meet the system requirements to run the software.
http://helpx.adobe.com/x-productkb/policy-pricing/system-requirements-premiere-pro.htmlhttp://www.adobe.com/products/premiere/tech-specs.html
The usual reason for not being able to download is that Premiere Pro (and other video apps such as After Effects) are 64 bit only so they require a 64 bit computer and a 64 bit operating system.
If you're running a 32 bit computer and operating system then you will not see the Premiere Pro icon since the software will not run on your computer.
Maybe you are looking for
-
Please also see attachment (same info as below). Background This code works in windows XP (32 bit), using/complied VS2005 with no problems. Please contact: Hamid Deljoo at work 416-867-8977 (8am to 4pm EST) Problem is: We are migrating this code from
-
I set up my work e-mail account on my iphone 4S. When I try to send an e-mail message from my phone, an error message occurs "Cannot Send Mail" - "recipient was rejected by the server because it does not allow relaying". What does this mean and how
-
Anyone else having trouble with home sharing? It was working fine just yesterday. Today, my AppleTV doesn't see my computer and I can't use AirPlay from my iPhone. I rebooted the AppleTV, which wasn't even able to connect to iTunes. It connected just
-
Amateur Radio Labview Applicatio​ns
In the past few years, Radio Amateurs have discovered the glories of software defined radios, SDRs. However, not every ham knows that Labview preceded the concept of SDR radios by quite a wide margin. Being able to reprogram a radio's functions on
-
Hope I made the right decision!!
After at least a couple of weeks of debate and reading these forums minimum of twice a day, I broke down and ordered a refurb 15" 1.67ghz Powerbook vs getting a MacBook Pro. Of course the sudden availability of refurb MacBook Pros at the Apple Store