Subversion Repositories javautils

Compare Revisions

Regard whitespace Rev 6 → Rev 7

/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/META-INF/taglib.tld
0,0 → 1,111
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>javamail</shortname>
<uri>http://java.sun.com/products/javamail/demo/webapp</uri>
<tag>
<name>listattachments</name>
<tagclass>demo.ListAttachmentsTag</tagclass>
<teiclass>demo.ListAttachmentsTEI</teiclass>
<bodycontent>JSP</bodycontent>
<info>
A listattachments tag
</info>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>messageinfo</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>listmessages</name>
<tagclass>demo.ListMessagesTag</tagclass>
<teiclass>demo.ListMessagesTEI</teiclass>
<bodycontent>JSP</bodycontent>
<info>
A listmessages tag
</info>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>folder</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>session</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>message</name>
<tagclass>demo.MessageTag</tagclass>
<teiclass>demo.MessageTEI</teiclass>
<bodycontent>empty</bodycontent>
<info>
A message tag
</info>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>folder</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>session</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>num</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>sendmail</name>
<tagclass>demo.SendTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>
An sendmail tag
</info>
<attribute>
<name>host</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>recipients</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>sender</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>subject</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/ListMessagesTag.java
0,0 → 1,139
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.mail.search.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
/**
* Custom tag for listing messages. The scripting variable is only
* within the body of the tag.
*/
public class ListMessagesTag extends BodyTagSupport {
private String folder;
private String session;
private int msgNum = 0;
private int messageCount = 0;
private Message message;
private Message[] messages;
private MessageInfo messageinfo;
/**
* folder attribute getter method.
*/
public String getFolder() {
return folder;
}
/**
* session attribute getter method.
*/
public String getSession() {
return session;
}
/**
* folder setter method.
*/
public void setFolder(String folder) {
this.folder = folder;
}
 
/**
* session attribute setter method.
*/
public void setSession(String session) {
this.session = session;
}
 
/**
* Method for processing the start of the tag.
*/
public int doStartTag() throws JspException {
messageinfo = new MessageInfo();
try {
Folder folder = (Folder)pageContext.getAttribute(
getFolder(), PageContext.SESSION_SCOPE);
FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.DELETED), false);
messages = folder.search(ft);
messageCount = messages.length;
msgNum = 0;
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
 
if (messageCount > 0) {
getMessage();
return BodyTag.EVAL_BODY_TAG;
} else
return BodyTag.SKIP_BODY;
}
/**
* Method for processing the body content of the tag.
*/
public int doAfterBody() throws JspException {
BodyContent body = getBodyContent();
try {
body.writeOut(getPreviousOut());
} catch (IOException e) {
throw new JspTagException("IterationTag: " + e.getMessage());
}
// clear up so the next time the body content is empty
body.clearBody();
if (msgNum < messageCount) {
getMessage();
return BodyTag.EVAL_BODY_TAG;
} else {
return BodyTag.SKIP_BODY;
}
}
/**
* Helper method for retrieving messages.
*/
private void getMessage() throws JspException {
message = messages[msgNum++];
messageinfo.setMessage(message);
pageContext.setAttribute(getId(), messageinfo);
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/MessageInfo.java
0,0 → 1,284
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.text.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
 
/**
* Used to store message information.
*/
public class MessageInfo {
private Message message;
/**
* Returns the bcc field.
*/
public String getBcc() throws MessagingException {
return formatAddresses(
message.getRecipients(Message.RecipientType.BCC));
}
/**
* Returns the body of the message (if it's plain text).
*/
public String getBody() throws MessagingException, java.io.IOException {
Object content = message.getContent();
if (message.isMimeType("text/plain")) {
return (String)content;
} else if (message.isMimeType("multipart/alternative")) {
Multipart mp = (Multipart)message.getContent();
int numParts = mp.getCount();
for (int i = 0; i < numParts; ++i) {
if (mp.getBodyPart(i).isMimeType("text/plain"))
return (String)mp.getBodyPart(i).getContent();
}
return "";
} else if (message.isMimeType("multipart/*")) {
Multipart mp = (Multipart)content;
if (mp.getBodyPart(0).isMimeType("text/plain"))
return (String)mp.getBodyPart(0).getContent();
else
return "";
} else
return "";
}
/**
* Returns the cc field.
*/
public String getCc() throws MessagingException {
return formatAddresses(
message.getRecipients(Message.RecipientType.CC));
}
/**
* Returns the date the message was sent (or received if the sent date
* is null.
*/
public String getDate() throws MessagingException {
Date date;
SimpleDateFormat df = new SimpleDateFormat("EE M/d/yy");
if ((date = message.getSentDate()) != null)
return (df.format(date));
else if ((date = message.getReceivedDate()) != null)
return (df.format(date));
else
return "";
}
/**
* Returns the from field.
*/
public String getFrom() throws MessagingException {
return formatAddresses(message.getFrom());
}
 
/**
* Returns the address to reply to.
*/
public String getReplyTo() throws MessagingException {
Address[] a = message.getReplyTo();
if (a.length > 0)
return ((InternetAddress)a[0]).getAddress();
else
return "";
}
/**
* Returns the javax.mail.Message object.
*/
public Message getMessage() {
return message;
}
/**
* Returns the message number.
*/
public String getNum() {
return (Integer.toString(message.getMessageNumber()));
}
/**
* Returns the received date field.
*/
public String getReceivedDate() throws MessagingException {
if (hasReceivedDate())
return (message.getReceivedDate().toString());
else
return "";
}
/**
* Returns the sent date field.
*/
public String getSentDate() throws MessagingException {
if (hasSentDate())
return (message.getSentDate().toString());
else
return "";
}
/**
* Returns the subject field.
*/
public String getSubject() throws MessagingException {
if (hasSubject())
return message.getSubject();
else
return "";
}
/**
* Returns the to field.
*/
public String getTo() throws MessagingException {
return formatAddresses(
message.getRecipients(Message.RecipientType.TO));
}
/**
* Method for checking if the message has attachments.
*/
public boolean hasAttachments() throws java.io.IOException,
MessagingException {
boolean hasAttachments = false;
if (message.isMimeType("multipart/*")) {
Multipart mp = (Multipart)message.getContent();
if (mp.getCount() > 1)
hasAttachments = true;
}
return hasAttachments;
}
/**
* Method for checking if the message has a bcc field.
*/
public boolean hasBcc() throws MessagingException {
return (message.getRecipients(Message.RecipientType.BCC) != null);
}
/**
* Method for checking if the message has a cc field.
*/
public boolean hasCc() throws MessagingException {
return (message.getRecipients(Message.RecipientType.CC) != null);
}
/**
* Method for checking if the message has a date field.
*/
public boolean hasDate() throws MessagingException {
return (hasSentDate() || hasReceivedDate());
}
/**
* Method for checking if the message has a from field.
*/
public boolean hasFrom() throws MessagingException {
return (message.getFrom() != null);
}
/**
* Method for checking if the message has the desired mime type.
*/
public boolean hasMimeType(String mimeType) throws MessagingException {
return message.isMimeType(mimeType);
}
/**
* Method for checking if the message has a received date field.
*/
public boolean hasReceivedDate() throws MessagingException {
return (message.getReceivedDate() != null);
}
/**
* Method for checking if the message has a sent date field.
*/
public boolean hasSentDate() throws MessagingException {
return (message.getSentDate() != null);
}
/**
* Method for checking if the message has a subject field.
*/
public boolean hasSubject() throws MessagingException {
return (message.getSubject() != null);
}
/**
* Method for checking if the message has a to field.
*/
public boolean hasTo() throws MessagingException {
return (message.getRecipients(Message.RecipientType.TO) != null);
}
/**
* Method for mapping a message to this MessageInfo class.
*/
public void setMessage(Message message) {
this.message = message;
}
 
/**
* Utility method for formatting msg header addresses.
*/
private String formatAddresses(Address[] addrs) {
if (addrs == null)
return "";
StringBuffer strBuf = new StringBuffer(getDisplayAddress(addrs[0]));
for (int i = 1; i < addrs.length; i++) {
strBuf.append(", ").append(getDisplayAddress(addrs[i]));
}
return strBuf.toString();
}
/**
* Utility method which returns a string suitable for msg header display.
*/
private String getDisplayAddress(Address a) {
String pers = null;
String addr = null;
if (a instanceof InternetAddress &&
((pers = ((InternetAddress)a).getPersonal()) != null)) {
addr = pers + " "+"&lt;"+((InternetAddress)a).getAddress()+"&gt;";
} else
addr = a.toString();
return addr;
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/MessageTag.java
0,0 → 1,108
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
/**
* Custom tag for retrieving a message.
*/
public class MessageTag extends TagSupport {
private String folder;
private String session;
private int num = 1;
 
/**
* folder attribute setter method.
*/
public String getFolder() {
return folder;
}
/**
* num attribute getter method.
*/
public String getNum() {
return Integer.toString(num);
}
/**
* session attribute getter method.
*/
public String getSession() {
return session;
}
/**
* folder setter method.
*/
public void setFolder(String folder) {
this.folder = folder;
}
 
/**
* num attribute setter method.
*/
public void setNum(String num) {
this.num = Integer.parseInt(num);
}
/**
* session attribute setter method.
*/
public void setSession(String session) {
this.session = session;
}
 
/**
* Method for processing the start of the tag.
*/
public int doStartTag() throws JspException {
MessageInfo messageinfo = new MessageInfo();
try {
Folder f = (Folder)pageContext.getAttribute(
getFolder(), PageContext.SESSION_SCOPE);
Message message = f.getMessage(num);
messageinfo.setMessage(message);
pageContext.setAttribute(getId(), messageinfo);
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
return SKIP_BODY;
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/ListAttachmentsTag.java
0,0 → 1,122
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
/**
* Custom tag for listing message attachments. The scripting variable is only
* within the body of the tag.
*/
public class ListAttachmentsTag extends BodyTagSupport {
private String messageinfo;
private int partNum = 1;
private int numParts = 0;
private AttachmentInfo attachmentinfo;
private MessageInfo messageInfo;
private Multipart multipart;
 
/**
* messageinfo attribute getter method.
*/
public String getMessageinfo() {
return messageinfo;
}
/**
* messageinfo attribute setter method.
*/
public void setMessageinfo(String messageinfo) {
this.messageinfo = messageinfo;
}
 
/**
* Method for processing the start of the tag.
*/
public int doStartTag() throws JspException {
messageInfo = (MessageInfo)pageContext.getAttribute(getMessageinfo());
attachmentinfo = new AttachmentInfo();
try {
multipart = (Multipart)messageInfo.getMessage().getContent();
numParts = multipart.getCount();
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
 
getPart();
 
return BodyTag.EVAL_BODY_TAG;
}
/**
* Method for processing the body content of the tag.
*/
public int doAfterBody() throws JspException {
BodyContent body = getBodyContent();
try {
body.writeOut(getPreviousOut());
} catch (IOException e) {
throw new JspTagException("IterationTag: " + e.getMessage());
}
// clear up so the next time the body content is empty
body.clearBody();
partNum++;
if (partNum < numParts) {
getPart();
return BodyTag.EVAL_BODY_TAG;
} else {
return BodyTag.SKIP_BODY;
}
}
/**
* Helper method for retrieving message parts.
*/
private void getPart() throws JspException {
try {
attachmentinfo.setPart(partNum, multipart.getBodyPart(partNum));
pageContext.setAttribute(getId(), attachmentinfo);
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/AttachmentInfo.java
0,0 → 1,141
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.io.*;
import java.util.*;
 
import javax.mail.*;
import javax.mail.internet.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
/**
* Used to store attachment information.
*/
public class AttachmentInfo {
private Part part;
private int num;
 
/**
* Returns the attachment's content type.
*/
public String getAttachmentType() throws MessagingException {
String contentType;
if ((contentType = part.getContentType()) == null)
return "invalid part";
else
return contentType;
}
 
/**
* Returns the attachment's content (if it is plain text).
*/
public String getContent() throws java.io.IOException, MessagingException {
if (hasMimeType("text/plain"))
return (String)part.getContent();
else
return "";
}
/**
* Returns the attachment's description.
*/
public String getDescription() throws MessagingException {
String description;
if ((description = part.getDescription()) != null)
return description;
else
return "";
}
/**
* Returns the attachment's filename.
*/
public String getFilename() throws MessagingException {
String filename;
if ((filename = part.getFileName()) != null)
return filename;
else
return "";
}
 
/**
* Returns the attachment number.
*/
public String getNum() {
return (Integer.toString(num));
}
/**
* Method for checking if the attachment has a description.
*/
public boolean hasDescription() throws MessagingException {
return (part.getDescription() != null);
}
/**
* Method for checking if the attachment has a filename.
*/
public boolean hasFilename() throws MessagingException {
return (part.getFileName() != null);
}
/**
* Method for checking if the attachment has the desired mime type.
*/
public boolean hasMimeType(String mimeType) throws MessagingException {
return part.isMimeType(mimeType);
}
/**
* Method for checking the content disposition.
*/
public boolean isInline() throws MessagingException {
if (part.getDisposition() != null)
return part.getDisposition().equals(Part.INLINE);
else
return true;
}
/**
* Method for mapping a message part to this AttachmentInfo class.
*/
public void setPart(int num, Part part)
throws MessagingException, ParseException {
this.part = part;
this.num = num;
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/ListMessagesTEI.java
0,0 → 1,55
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
/**
* Extra information class to support the scripting variable created by the
* ListMessagesTag class. The scope of the variable is limited to the body
* of the tag.
*/
public class ListMessagesTEI extends TagExtraInfo {
public ListMessagesTEI() {
super();
}
public VariableInfo[] getVariableInfo(TagData data) {
VariableInfo info = new VariableInfo(data.getId(),"MessageInfo",
true, VariableInfo.NESTED);
VariableInfo[] varInfo = { info };
return varInfo;
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/SendTag.java
0,0 → 1,141
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.util.*;
import java.net.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
/**
* Custom tag for sending messages.
*/
public class SendTag extends BodyTagSupport {
private String body;
private String cc;
private String host;
private String recipients;
private String sender;
private String subject;
 
/**
* host attribute setter method.
*/
public void setHost(String host) {
this.host = host;
}
/**
* recipient attribute setter method.
*/
public void setRecipients(String recipients) {
this.recipients = recipients;
}
 
/**
* sender attribute setter method.
*/
public void setSender(String sender) {
this.sender = sender;
}
 
/**
* cc attribute setter method.
*/
public void setCc(String cc) {
this.cc = cc;
}
 
/**
* subject attribute setter method.
*/
public void setSubject(String subject) {
this.subject = subject;
}
 
/**
* Method for processing the end of the tag.
*/
public int doEndTag() throws JspException {
Properties props = System.getProperties();
try {
if (host != null)
props.put("mail.smtp.host", host);
else if (props.getProperty("mail.smtp.host") == null)
props.put("mail.smtp.host", InetAddress.getLocalHost().
getHostName());
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
InternetAddress[] toAddrs = null, ccAddrs = null;
 
try {
if (recipients != null) {
toAddrs = InternetAddress.parse(recipients, false);
msg.setRecipients(Message.RecipientType.TO, toAddrs);
} else
throw new JspException("No recipient address specified");
 
if (sender != null)
msg.setFrom(new InternetAddress(sender));
else
throw new JspException("No sender address specified");
 
if (cc != null) {
ccAddrs = InternetAddress.parse(cc, false);
msg.setRecipients(Message.RecipientType.CC, ccAddrs);
}
 
if (subject != null)
msg.setSubject(subject);
 
if ((body = getBodyContent().getString()) != null)
msg.setText(body);
else
msg.setText("");
 
Transport.send(msg);
} catch (Exception ex) {
throw new JspException(ex.getMessage());
}
 
return(EVAL_PAGE);
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/MessageTEI.java
0,0 → 1,55
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
/**
* Extra information class to support the scripting variable created by the
* MessagesTag class. The variable exists outside of the tag.
*
*/
public class MessageTEI extends TagExtraInfo {
public MessageTEI() {
super();
}
public VariableInfo[] getVariableInfo(TagData data) {
VariableInfo info = new VariableInfo(data.getId(),"MessageInfo",
true, VariableInfo.AT_END);
VariableInfo[] varInfo = { info };
return varInfo;
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/taglib/demo/ListAttachmentsTEI.java
0,0 → 1,55
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
 
/**
* Extra information class to support the scripting variable created by the
* ListAttachmentsTag class. The scope of the variable is limited to the body
* of the tag.
*/
public class ListAttachmentsTEI extends TagExtraInfo {
public ListAttachmentsTEI() {
super();
}
public VariableInfo[] getVariableInfo(TagData data) {
VariableInfo info = new VariableInfo(data.getId(),"AttachmentInfo",
true, VariableInfo.NESTED);
VariableInfo[] varInfo = { info };
return varInfo;
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/compose.jsp
0,0 → 1,86
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page language="java" %>
<%@ page errorPage="errorpage.jsp" %>
 
<html>
<head>
<title>JavaMail compose</title>
</head>
 
<body bgcolor="#ccccff">
<form ACTION="send" METHOD=POST>
<input type="hidden" name="send" value="send">
<p align="center">
<b><font size="4" face="Verdana, Arial, Helvetica">
JavaMail Compose Message</font></b>
<p>
<table border="0" width="100%">
<tr>
<td width="16%" height="22">
<p align="right">
<b><font face="Verdana, Arial, Helvetica">To:</font></b></td>
<td width="84%" height="22">
<% if (request.getParameter("to") != null) { %>
<input type="text" name="to" value="<%= request.getParameter("to") %>" size="30">
<% } else { %>
<input type="text" name="to" size="30">
<% } %>
<font size="1" face="Verdana, Arial, Helvetica">
(separate addresses with commas)</font></td></tr>
<tr>
<td width="16%"><p align="right">
<b><font face="Verdana, Arial, Helvetica">From:</font></b></td>
<td width="84%">
<input type="text" name="from" size="30">
<font size="1" face="Verdana, Arial, Helvetica">
(separate addresses with commas)</font></td></tr>
<tr>
<td width="16%"><p align="right">
<b><font face="Verdana, Arial, Helvetica">Subject:</font></b></td>
<td width="84%">
<input type="text" name="subject" size="55"></td></tr>
<tr>
<td width="16%">&nbsp;</td>
<td width="84%"><textarea name="text" rows="15" cols="53"></textarea></td></tr>
<tr>
<td width="16%" height="32">&nbsp;</td>
<td width="84%" height="32">
<input type="submit" name="Send" value="Send">
<input type="reset" name="Reset" value="Reset"></td></tr>
</table>
</form>
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/errorpage.jsp
0,0 → 1,47
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page isErrorPage="true" %>
<html>
<head>
<title>JavaMail errorpage</title>
</head>
<body bgcolor="white">
<form ACTION="errordetails" METHOD=POST>
<% session.putValue("details", exception.toString()); %>
<h2>An error occured while attempting to perform the operation you requested.
</h2>
<input type="submit" name="Error Details" value="Error Details">
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/login.jsp
0,0 → 1,56
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page language="java" import="demo.MailUserBean" %>
<%@ page errorPage="errorpage.jsp" %>
<jsp:useBean id="mailuser" scope="session" class="demo.MailUserBean" />
 
<html>
<head>
<title>JavaMail login</title>
</head>
<body bgcolor="white">
<%
mailuser.login(request.getParameter("hostname"),
request.getParameter("username"),
request.getParameter("password"));
session.setAttribute("folder", mailuser.getFolder());
%>
 
<jsp:forward page="folders.jsp" />
 
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/logout.jsp
0,0 → 1,49
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page language="java" import="demo.MailUserBean" %>
<%@ page errorPage="errorpage.jsp" %>
<jsp:useBean id="mailuser" scope="session" class="demo.MailUserBean" />
 
<html>
<head>
<title>JavaMail logout</title>
</head>
 
<% mailuser.logout(); %>
 
<body>
<h2>Logged out OK</h2><a href=index.html>click here to login</a>
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/send.jsp
0,0 → 1,57
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page language="java" %>
<%@ page errorPage="errorpage.jsp" %>
<%@ taglib uri="http://java.sun.com/products/javamail/demo/webapp"
prefix="javamail" %>
<html>
<head>
<title>JavaMail send</title>
</head>
<body bgcolor="white">
<javamail:sendmail
recipients="<%= request.getParameter(\"to\") %>"
sender="<%= request.getParameter(\"from\") %>"
subject="<%= request.getParameter(\"subject\") %>"
>
<%= request.getParameter("text") %>
</javamail:sendmail>
<h1>Message sent successfully</h1>
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/WEB-INF/web.xml
0,0 → 1,59
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
 
<web-app>
<display-name>JspDemo</display-name>
<description>no description</description>
<servlet>
<servlet-name>FilterServlet</servlet-name>
<display-name>FilterServlet</display-name>
<description>no description</description>
<servlet-class>demo.FilterServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>AttachmentServlet</servlet-name>
<display-name>AttachmentServlet</display-name>
<description>no description</description>
<servlet-class>demo.AttachmentServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FilterServlet</servlet-name>
<url-pattern>/compose</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FilterServlet</servlet-name>
<url-pattern>/errordetails</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FilterServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FilterServlet</servlet-name>
<url-pattern>/logout</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FilterServlet</servlet-name>
<url-pattern>/send</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FilterServlet</servlet-name>
<url-pattern>/messageheaders</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FilterServlet</servlet-name>
<url-pattern>/messagecontent</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AttachmentServlet</servlet-name>
<url-pattern>/attachment</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>http://java.sun.com/products/javamail/demo/webapp</taglib-uri>
<taglib-location>/WEB-INF/lib/jtl.jar</taglib-location>
</taglib>
<resource-ref>
<res-ref-name>MySession</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/folders.jsp
0,0 → 1,66
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page language="java" import="javax.mail.*, demo.MailUserBean" %>
<%@ page errorPage="errorpage.jsp" %>
<jsp:useBean id="mailuser" scope="session" class="demo.MailUserBean" />
<html>
<head>
<title>JavaMail folders</title>
</head>
<body bgcolor="#ccccff">
 
<center>
<font face="Arial,Helvetica" font size=+3>
<b>Welcome to JavaMail!</b> </font> </center>
<table width="50%" border=0 align=center>
<tr>
<td width="75%" bgcolor="#ffffcc">
<font face="Arial, Helvetica" font size=-1>
<b>FolderName</b></font></td><br>
<td width="25%" bgcolor="#ffffcc">
<font face="Arial, Helvetica" font size=-1>
<b>Messages</b></font></td><br>
</tr>
<tr>
<td width="75%" bgcolor="#ffffff">
<a href="messageheaders">Inbox</a></td><br>
<td width="25%" bgcolor="#ffffff">
<%= mailuser.getMessageCount() %>
</tr>
</table>
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/errordetails.jsp
0,0 → 1,43
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page isErrorPage="true" %>
<html>
<head>
<title>JavaMail errordetails</title>
</head>
<body bgcolor="white">
<%= session.getValue("details") %>
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/index.html
0,0 → 1,113
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<!--
 
Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of Sun Microsystems nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
 
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
<TITLE>JavaMail</TITLE>
</HEAD>
 
<BODY BGCOLOR="#CCCCFF">
 
<FORM ACTION="login" METHOD=POST ENCTYPE="application/x-www-form-urlencoded">
<P ALIGN="CENTER"><B><FONT SIZE="5" FACE="Arial, Helvetica">Welcome to JavaMail</FONT></B></P>
 
<P ALIGN="CENTER"><B><FONT SIZE="5" FACE="Arial, Helvetica">HTML Email Reader Demo</FONT></B></P>
<CENTER>
<P>
<TABLE BORDER="0" WIDTH="100%">
<TR>
<TD WIDTH="40%">
<P ALIGN="RIGHT"><FONT FACE="Arial, Helvetica">IMAP Hostname:</FONT>
</TD>
<TD WIDTH="60%"><INPUT TYPE="TEXT" NAME="hostname" SIZE="25"></TD>
</TR>
<TR>
<TD WIDTH="40%">
<P ALIGN="RIGHT"><FONT FACE="Arial, Helvetica">Username:</FONT>
</TD>
<TD WIDTH="60%"><INPUT TYPE="TEXT" NAME="username" SIZE="25"></TD>
</TR>
<TR>
<TD WIDTH="40%">
<P ALIGN="RIGHT"><FONT FACE="Arial, Helvetica">Password:</FONT>
</TD>
<TD WIDTH="60%"><INPUT TYPE="PASSWORD" NAME="password" SIZE="25"></TD>
</TR>
</TABLE>
<INPUT TYPE="SUBMIT" VALUE="Login"><INPUT TYPE="RESET" NAME="Reset" VALUE="Reset"></P>
</CENTER>
<P>
<HR ALIGN="CENTER">
</P>
<P><B><I><FONT FACE="Arial, Helvetica">Overview:</FONT></I></B></P>
 
<FONT SIZE="2" FACE="Arial, Helvetica">
<b>THIS IS A DEMO!!!</b> Please see the webapp.README.txt
file for information on how to
compile and run the web application.<br> <br>
This demo illustrates the use of JavaMail APIs in a 3-tiered web
application. It allows the user to login to an
IMAP store, list all the messages in the INBOX folder, view
selected messages, compose and send a message, and logout.
</FONT>
 
<P><B><I><FONT FACE="Arial, Helvetica">Features:</FONT></I></B></P>
 
<UL>
<LI><FONT SIZE="2" FACE="Arial, Helvetica">HTML access to your IMAP mailbox</FONT>
<LI><FONT SIZE="2" FACE="Arial, Helvetica">Proxy-able anywhere HTTP can be proxied</FONT>
<LI><FONT SIZE="2" FACE="Arial, Helvetica">Easy to use</FONT>
<LI><FONT SIZE="2" FACE="Arial, Helvetica">Uses web browser's content handling capabilities</FONT>
</UL>
 
<P><B><I><FONT FACE="Arial, Helvetica">Limitations:</FONT></I></B></P>
 
<UL>
<LI><FONT SIZE="2" FACE="Arial, Helvetica">Only INBOX support (no user folders)</FONT>
<LI><FONT SIZE="2" FACE="Arial, Helvetica">Can't delete, copy, move, print, save, forward, reply to, search in
messages --<BR>
but it could be done</FONT>
<LI><FONT SIZE="2" FACE="Arial, Helvetica">Doesn't check for new messages (have to log out and log back it)</FONT>
</UL>
 
<P>
<HR ALIGN="CENTER">
</P>
 
<P><FONT FACE="Arial, Helvetica">Feedback to </FONT><A HREF="mailto:javamail@Sun.COM"><FONT FACE="Arial, Helvetica">javamail@Sun.COM</FONT></A>
</FORM>
 
</BODY>
 
</HTML>
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/messagecontent.jsp
0,0 → 1,117
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page language="java" import="demo.MessageInfo, demo.AttachmentInfo" %>
<%@ page errorPage="errorpage.jsp" %>
<%@ taglib uri="http://java.sun.com/products/javamail/demo/webapp"
prefix="javamail" %>
 
<html>
<head>
<title>JavaMail messagecontent</title>
</head>
 
<javamail:message
id="msginfo"
folder="folder"
num="<%= request.getParameter(\"message\") %>"
/>
 
<body bgcolor="#ccccff">
<center><font face="Arial,Helvetica" font size="+3">
<b>Message<sp>
<sp>in folder /INBOX</b></font></center><p>
 
<%-- first, display this message's headers --%>
<b>Date:</b>
<%= msginfo.getSentDate() %>
<br>
<% if (msginfo.hasFrom()) { %>
<b>From:</b>
<a href="compose?to=<%= msginfo.getReplyTo() %>"
target="reply<%= msginfo.getNum() %>">
<%= msginfo.getFrom() %>
</a>
<br>
<% } %>
 
<% if (msginfo.hasTo()) { %>
<b>To:</b>
<%= msginfo.getTo() %>
<br>
<% } %>
 
<% if (msginfo.hasCc()) { %>
<b>CC:</b>
<%= msginfo.getCc() %>
<br>
<% } %>
 
<b>Subject:</b>
<% if (msginfo.hasSubject()) { %>
<%= msginfo.getSubject() %>
<% } %>
<br>
<pre>
<%= msginfo.getBody() %>
</pre>
<% if (msginfo.hasAttachments()) { %>
<javamail:listattachments
id="attachment"
messageinfo="msginfo">
<p><hr>
<b>Attachment Type:</b>
<%= attachment.getAttachmentType() %>
<br>
<% if (attachment.hasMimeType("text/plain") &&
attachment.isInline()){ %>
<pre>
<%= attachment.getContent() %>
</pre>
<% } else { %>
<b>Filename:</b>
<%= attachment.getFilename() %>
<br>
<b>Description:</b>
<%= attachment.getDescription() %>
<br>
<a href="attachment?message=
<%= msginfo.getNum() %>&part=<%= attachment.getNum() %>">
Display Attachment</a>
<% } %>
</javamail:listattachments>
<% } %>
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/docroot/messageheaders.jsp
0,0 → 1,103
<%--
%
% Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% - Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
%
% - Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in the
% documentation and/or other materials provided with the distribution.
%
% - Neither the name of Sun Microsystems nor the names of its
% contributors may be used to endorse or promote products derived
% from this software without specific prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
% IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
% THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
% PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
% CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
% PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
% LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
% NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%
--%>
 
<%@ page language="java" import="demo.MessageInfo" %>
<%@ page errorPage="errorpage.jsp" %>
<%@ taglib uri="http://java.sun.com/products/javamail/demo/webapp"
prefix="javamail" %>
 
<html>
<head>
<title>JavaMail messageheaders</title>
</head>
 
<body bgcolor="#ccccff"><hr>
<center><font face="Arial,Helvetica" font size="+3">
<b>Folder INBOX</b></font></center><p>
<font face="Arial,Helvetica" font size="+3">
<b><a href="logout">Logout</a>
<a href="compose" target="compose">Compose</a>
</b></font>
<hr>
<table cellpadding=1 cellspacing=1 width="100%" border=1>
<tr>
<td width="25%" bgcolor="ffffcc">
<font face="Arial,Helvetica" font size="+1">
<b>Sender</b></font></td>
<td width="15%" bgcolor="ffffcc">
<font face="Arial,Helvetica" font size="+1">
<b>Date</b></font></td>
<td bgcolor="ffffcc">
<font face="Arial,Helvetica" font size="+1">
<b>Subject</b></font></td>
</tr>
<javamail:listmessages
id="msginfo"
folder="folder">
<%-- from --%>
<tr valign=middle>
<td width="25%" bgcolor="ffffff">
<font face="Arial,Helvetica">
<% if (msginfo.hasFrom()) { %>
<%= msginfo.getFrom() %>
</font>
<% } else { %>
<font face="Arial,Helvetica,sans-serif">
Unknown
<% } %>
</font></td>
<%-- date --%>
<td nowrap width="15%" bgcolor="ffffff">
<font face="Arial,Helvetica">
<%= msginfo.getDate() %>
</font></td>
<%-- subject & link --%>
<td bgcolor="ffffff">
<font face="Arial,Helvetica">
<a href="messagecontent?message=<%= msginfo.getNum() %>">
<% if (msginfo.hasSubject()) { %>
<%= msginfo.getSubject() %>
<% } else { %>
<i>No Subject</i>
<% } %>
</a>
</font></td>
</tr>
</javamail:listmessages>
</table>
</body>
</html>
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/classes/demo/MailUserBean.java
0,0 → 1,210
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.util.*;
import javax.mail.*;
import javax.naming.*;
 
/**
* This JavaBean is used to store mail user information.
*/
public class MailUserBean {
private Folder folder;
private String hostname;
private String username;
private String password;
private Session session;
private Store store;
private URLName url;
private String protocol = "imap";
private String mbox = "INBOX";
 
public MailUserBean(){}
 
/**
* Returns the javax.mail.Folder object.
*/
public Folder getFolder() {
return folder;
}
/**
* Returns the number of messages in the folder.
*/
public int getMessageCount() throws MessagingException {
return folder.getMessageCount();
}
 
/**
* hostname getter method.
*/
public String getHostname() {
return hostname;
}
/**
* hostname setter method.
*/
public void setHostname(String hostname) {
this.hostname = hostname;
}
/**
* username getter method.
*/
public String getUsername() {
return username;
}
 
/**
* username setter method.
*/
public void setUsername(String username) {
this.username = username;
}
 
/**
* password getter method.
*/
public String getPassword() {
return password;
}
 
/**
* password setter method.
*/
public void setPassword(String password) {
this.password = password;
}
 
/**
* session getter method.
*/
public Session getSession() {
return session;
}
 
/**
* session setter method.
*/
public void setSession(Session session) {
this.session = session;
}
 
/**
* store getter method.
*/
public Store getStore() {
return store;
}
 
/**
* store setter method.
*/
public void setStore(Store store) {
this.store = store;
}
 
/**
* url getter method.
*/
public URLName getUrl() {
return url;
}
 
/**
* Method for checking if the user is logged in.
*/
public boolean isLoggedIn() {
return store.isConnected();
}
/**
* Method used to login to the mail host.
*/
public void login() throws Exception {
url = new URLName(protocol, getHostname(), -1, mbox,
getUsername(), getPassword());
/*
* First, try to get the session from JNDI,
* as would be done under J2EE.
*/
try {
InitialContext ic = new InitialContext();
Context ctx = (Context)ic.lookup("java:comp/env");
session = (Session)ctx.lookup("MySession");
} catch (Exception ex) {
// ignore it
}
 
// if JNDI fails, try the old way that should work everywhere
if (session == null) {
Properties props = null;
try {
props = System.getProperties();
} catch (SecurityException sex) {
props = new Properties();
}
session = Session.getInstance(props, null);
}
store = session.getStore(url);
store.connect();
folder = store.getFolder(url);
folder.open(Folder.READ_WRITE);
}
 
/**
* Method used to login to the mail host.
*/
public void login(String hostname, String username, String password)
throws Exception {
this.hostname = hostname;
this.username = username;
this.password = password;
login();
}
 
/**
* Method used to logout from the mail host.
*/
public void logout() throws MessagingException {
folder.close(false);
store.close();
store = null;
session = null;
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/classes/demo/FilterServlet.java
0,0 → 1,83
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
/**
* This servlet is used to determine whether the user is logged in before
* forwarding the request to the selected URL.
*/
public class FilterServlet extends HttpServlet {
 
/**
* This method handles the "POST" submission from two forms: the
* login form and the message compose form.
*/
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
 
String servletPath = request.getServletPath();
servletPath = servletPath.concat(".jsp");
getServletConfig().getServletContext().
getRequestDispatcher("/" + servletPath).forward(request, response);
}
 
/**
* This method handles the GET requests from the client.
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// check to be sure we're still logged in
// before forwarding the request.
HttpSession session = request.getSession();
MailUserBean mailuser = (MailUserBean)session.getAttribute("mailuser");
String servletPath = request.getServletPath();
servletPath = servletPath.concat(".jsp");
if (mailuser.isLoggedIn())
getServletConfig().getServletContext().
getRequestDispatcher("/" + servletPath).
forward(request, response);
else
getServletConfig().getServletContext().
getRequestDispatcher("/index.html").
forward(request, response);
}
}
 
/ViaThinkSoft Java Utils/lib/javamail-1.4.3/demo/webapp/src/classes/demo/AttachmentServlet.java
0,0 → 1,93
/*
* Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
package demo;
 
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
/**
* This servlet gets the input stream for a given msg part and
* pushes it out to the browser with the correct content type.
* Used to display attachments and relies on the browser's
* content handling capabilities.
*/
public class AttachmentServlet extends HttpServlet {
 
/**
* This method handles the GET requests from the client.
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
HttpSession session = request.getSession();
ServletOutputStream out = response.getOutputStream();
int msgNum = Integer.parseInt(request.getParameter("message"));
int partNum = Integer.parseInt(request.getParameter("part"));
MailUserBean mailuser = (MailUserBean)session.getAttribute("mailuser");
 
// check to be sure we're still logged in
if (mailuser.isLoggedIn()) {
try {
Message msg = mailuser.getFolder().getMessage(msgNum);
 
Multipart multipart = (Multipart)msg.getContent();
Part part = multipart.getBodyPart(partNum);
String sct = part.getContentType();
if (sct == null) {
out.println("invalid part");
return;
}
ContentType ct = new ContentType(sct);
 
response.setContentType(ct.getBaseType());
InputStream is = part.getInputStream();
int i;
while ((i = is.read()) != -1)
out.write(i);
out.flush();
out.close();
 
} catch (MessagingException ex) {
throw new ServletException(ex.getMessage());
}
} else {
getServletConfig().getServletContext().
getRequestDispatcher("/index.html").
forward(request, response);
}
}
}