David Meyers

Greenhorn
+ Follow
since Jul 03, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by David Meyers

Try adding the struts jar to your weblogic classpath
23 years ago
What/where is the brainbench test? Anyway, I've heard of people passing without Larman. I'm currently reading Larman, but haven't got to anything that wasn't included in UML Distilled.
thanks
Yes, that is a correct post in regards to relationships. However in Java, Static is shared by all instances of the class, but can change, unless it is final, in a final class, or in an interface.
I would definitely model TicketEntries as dependent objects of Ticket, and not as an EJB. It shouldn't be too complex to insert calls to queries when you want to add update or delete the TicketEntries.
A little extra work will make performance much better.
Goto http://www-1.ibm.com/certify/tests/obj486.shtml
you'll have to register, but its free.
Click on the sample test link.
Ok, so I got it to send a zip file using piped input and piped output, but I'm getting a deadlock situation. I can't use new threads becuase I am inside a j2ee application (that would break the contract). My code is below. Any suggestions?
//pipe the output to the input
PipedInputStream in = new PipedInputStream();
OutputStream out = new PipedOutputStream(in);
ZipOutputStream zipOut = new ZipOutputStream(out);
ZipEntry zipEntry = new ZipEntry(attachmentName + ".txt");
zipOut.putNextEntry(zipEntry);
zipOut.write(attachmentString.getBytes());
zipOut.closeEntry();
zipOut.close();
out.close();
MimeBodyPart part = new MimeBodyPart(in);
23 years ago
I know of no way of doing what you are asking. How many different methods may you be calling? If there aren't that many you have several options.
A) If only 2 choices pass a boolean and call the proper methd based on this parameter.
B) If many choices pass an int and create an Interface with constants where numbers stand for a method. Then use a switch statement in your method to call other methods based on this parameter.
If neither of those solutions will work, perhaps a little more info on what you are trying to do would help.
Good luck,
Dave
23 years ago
I'm trying to send an email with an attachement that is a zip file. However I don't actually have a file. I create a String that is extremely large, which I want to attach to a MimeMessage as a zip file. The problem is that MimeBodyPart takes an InputStream, but I have an OutputStream at this point.
Here is what I've tried so far (note imports are at the end):
/**
* Create the MimeMessage that will be sent as an email
*/
private static MimeMessage createMime(String attachmentString,
String attachmentName, String from, String subject,
List toEmailAddresses) {
MimeMessage msg = new MimeMessage();
MimeBodyPart part = null;
try {
FileOutputStream outStream = new FileOutputStream
("out.zip");
ZipOutputStream zipOut = new ZipOutputStream(outStream);
zipOut.setMethod(ZipOutputStream.DEFLATED);
ZipEntry zipEntry = new ZipEntry(attachmentName);
zipOut.putNextEntry(zipEntry);
zipOut.write(attachmentString.getBytes("US-ASCII"));
zipOut.flush();
part = new MimeBodyPart();
part.putByteStream(zipOut);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ie) {
ie.printStackTrace();
}
part.addHeader(Constants.contentType, "application/x-zip-compressed");
part.setEncoding(MimePart.BASE64);
part.setDisposition(MimePart.ATTACHMENT);
part.setFileName("ZipFile.txt");
msg.setContent(part, "");
msg.addHeader(Header.SUBJECT, subject);
if (toEmailAddresses != null && !toEmailAddresses.isEmpty()) {
int emailSize = toEmailAddresses.size();
InternetAddress[] to = new InternetAddress[emailSize];
for (int i = 0; i < emailSize; i++) {
String email = (String)toEmailAddresses.get(i);
if (email != null) {
to[i] = new InternetAddress(email);
}
}
msg.addRecipients(MimeMessage.TO, to);
}
msg.addHeader(Header.FROM, from);
return msg;
}

import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import com.ibm.network.mail.smtp.protocol.CoreProtocolBean;
import com.ibm.network.mail.smtp.event.MessageEvent;
import com.ibm.network.mail.smtp.event.StatusEvent;
import com.ibm.network.mail.smtp.event.StatusListener;
import com.ibm.network.mail.base.Constants;
import com.ibm.network.mail.base.InternetAddress;
import com.ibm.network.mail.base.Header;
import com.ibm.network.mail.base.MimeMessage;
import com.ibm.network.mail.base.MimeBodyPart;
import com.ibm.network.mail.base.MimePart;
23 years ago
I would recommend in interface in cases where you aren't implementing any of the methods in the abstract class. This is because you can always implement multiple interfaces, but are limited to one extend.
Good luck