Server-Side Development Section Index | Page 8
How do I find out the number of deleted messages in a folder?
Added with JavaMail 1.3, the getDeletedMessageCount() method of Folder gets this for you. A -1 may be returned if the server doesn't support the operation.
How do I get the sender of an email?
The getFrom() of Message is one way, but the getSender() method of MimeMessage reads the RFC 822 Sender header field. A value of null is returned if the header isn't present. Comparing the two all...more
How can I prevent my public JSP page from appearing within the search results of an engine like Google or Yahoo?
You can add a meta tag to the generated HTML content indicating that the page must not be indexed by the search engine's spider.
<head>
<meta name="robots" content="noindex">
...
<...more
Brief description on the 4 interfaces applicable to EJBs (Remote, Local, Home, LocalHome): when to use them and the differences between them?
The Remote and Home interfaces have somewhat misleading names, because both interfaces are used by the EJB client, which may be on a "remote" machine.
You will need to use both when working with ...more
How do I calculate the size of an entire folder?
For POP3, you can get this information for the INBOx with <size=2>com.sun.mail.pop3.POP3Folder.getSize()</size>.
For IMAP, the protocol doesn't support this feature. You would need to ...more
How do I package a JavaMail application into a single jar file along with the mail.jar and activation.jar?
You need to unjar all the JAR files into a single directory tree and then JAR them back up. The trick is preserving the location of some files:
425 Fri Dec 01 00:05:16 EST 2000 META-INF/javam...more
How do I get rid of unused connections? Doing something like checking for the existance of an IMAP folder leaves the connection open.
You can set the connection pool timeout property (mail.imap.connectionpooltimeout for imap). Then... according to JavaMail architect Bill Shannon:
Because JavaMail doesn't use a separate thread t...more
Cross Site Scripting (XSS) with Jakarta Tomcat.
Hi,
The XSS vulnerability has been found at the time Tomcat 4.0.3 has been released (and 4.1.2 was in beta). The problem was connected to the fact that it was possible to run some specific classes...more
EJB is scalable because it can run in cluster environment. What is there in EJB specification and in Application Server that supports this feature ?
EJB and scalability
EJB is scalable because it can run in cluster environment. What is there in EJB specification and in Application Server that supports this feature ?
Tomcat 4.x and servlet mapping.
Tomcat 4.x and /servlet/ mapping.
What can be done using the session object once it has been invalidated?
What can be done using the session object once it has been invalidated?
What can be done using the session object once it has been
invalidated?
The JSP spec is not very clear on this.
Can I use i...more
What is the scope of <%@ page errorPage="" %>? Does it get passed to jsp:forwarded pages? Does it get passed to jsp:included pages?
Well, I did some experimentation and found out that
errorPage is passed on to forwarded and included pages.
The forwaded or included page can always override the
errorPage with own <%@ page err...more
Synchronization of Stateless Session bean instances. Is there anyway by which we can update/modify (not on server start up but at actual application run time) value of instance variables of ll stateless session bean instances present in the pool??
Additional Note
This is something related to snchronizing all the instances. If a user modify a variable in Stateless Session Bean can it be reflected to all other instances in the pool? so that ...more
How do I find out if an IMAP server supports a particular capability?
If you have a folder open, you can do this:
import com.sun.mail.imap.IMAPFolder;
import com.sun.mail.imap.protocol.IMAPProtocol;
IMAPProtocol p = ((IMAPFolder)folder).getProtocol();
...more
I am writing a simple jsp to retrieve and save from/to my MySQL db. My retrieve and save functions work great. Now, depending on the action in the browser, I would only like to invoke one of the methods. For example, for the onChange event, I would like to get the info from the db. For the onClick event, I would like to save the info to the db. Considering these actions are on the client side and jsp is on the server side, is there a way to do this? If not, does anyone have a suggestion on how this can be done?
I am writing a simple jsp to retrieve and save from/to my MySQL db. My retrieve and save functions work great. Now, depending on the action in the browser, I would only like to invoke one of the m...more