Bashar Ayyash

Ranch Hand
+ Follow
since Jun 24, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Bashar Ayyash

Hi Guys,

I'm confused!!! I read an article about Ajax frameworks, so why I need to learn Ajax if I can use Ajax framwrok (which is simpler in programming and implementing).

I need your advice,
OK,,,, that is fine with me as long as it gives us a small introduction and basic knowledge in Ajax, because I'm Java programmer I assume it will be easy to understand.....


Thank you,,,,,

Originally posted by v joshi:
...I am also interested in learning Ajax. Does this book comes along with CD? Is this book for the people who don't know ajax at all or it requires some basic knowledge?



Yes joshi, I agree with you that this book must cover basic knowlege for developers new to Ajax....
Does this book contain tutorials? because I find tutorials easier to understand than long context and explanations...

Regards,
ok thanks,,,,, but does "Ajax for Web Application Developers" talks about how to implement Ajax in JAVA, in PHP or it talks about Ajax in general?

Regards,
Hi Kris,

I'm interested in Ajax because I heared from all the people around me and I read on the net articles about Ajax. So I want to learn and use Ajax in my work.

As Ajax beginner programmer would I find easy to understand?
Does your book lead me from A-to-Z in Ajax world?

Best Regards,
[ December 20, 2006: Message edited by: Bashar Ayyash ]
Thank you guys, you were all most helpfull.
Here is the correct codes:

mbp2.setFileName("Clearance.pdf");

mbp2.setDataHandler(new DataHandler(new ByteArrayDataSource(baos.toByteArray(),"application/pdf")));

We must specifiy the type in ByteArrayDataSource.

Regards,
[ July 23, 2006: Message edited by: Bashar Ayyash ]
18 years ago
Hello guys,

can any body help me with the above code, as I mentioned earlier, I can successfully send an attachment of the generated pdf with the e-mail but at the other side the user can see the e-mail but without an attachmen.

Any help is realy appreciated.

Regards,
18 years ago
Hi Ulf,

Thank you?, I attached the pdf correctly, but there is one problem. When I open the e-mail at the recipient person, I don't see/download the attached file? Where is the error in my code?:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document(PageSize.A4, 10, 10, 10, 10);
try {
PdfWriter writer = PdfWriter.getInstance(document, baos);
document.open();

PdfPTable outerTable = new PdfPTable(1);
Font titleFont = new Font(helvetica, 21, Font.NORMAL);
PdfPCell cell = new PdfPCell(new Paragraph("Address\n\n\n", titleFont));
outerTable.addCell(cell);
cell = new PdfPCell(new Paragraph("Date: " + new java.util.Date()));
outerTable.addCell(cell);

document.add(outerTable);

document.close();
} catch (DocumentException e) {
e.printStackTrace();
}
//resp.setContentType("application/pdf");
baos.flush();

//Generating an email with the attachment
String to = "bashar@ayyashelectra.com";
String from = "bashar@hotmail.com";
String host = "localhost";
boolean debug = true;
PrintWriter out = response.getWriter();

Properties props = new Properties();
props.put("mail.smtp.host", host);

Session session = Session.getInstance(props, null);
session.setDebug(debug);
try{
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
// msg.setRecipients(Message.RecipientType.CC, address);
msg.setSubject("JAVAMail APIs Multipart Test");
msg.setSentDate(new Date());

//Create and fill the first message
MimeBodyPart mpb1 = new MimeBodyPart();
mpb1.setText(msgText1);

//Create ByteArrayInputStream object
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

//Create and fill the second message part
MimeBodyPart mbp2 = new MimeBodyPart(bais);


//Create multipart
Multipart mp = new MimeMultipart();
mp.addBodyPart(mpb1);
mp.addBodyPart(mbp2);

//add the multipart to the message
msg.setContent(mp);

Transport.send(msg);
}catch (MessagingException mex){
mex.printStackTrace();
Exception ex = null;
if((ex = mex.getNextException()) != null){
ex.printStackTrace();
}
}
//---->

Regards,
18 years ago
Could you give me an example, please?
18 years ago
Here is an example to the code needed to generate PDF document, the codes are in a servlet doPost method :

ServletOutputStream out = response.getOutputStream();
Document document = new Document(PageSize.A4, 10, 10, 10, 10);
try {
PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
document.open();

PdfPTable outerTable = new PdfPTable(1);
Font titleFont = new Font(helvetica, 21, Font.NORMAL);
PdfPCell cell = new PdfPCell(new Paragraph("Address\n\n\n", titleFont));
outerTable.addCell(cell);
cell = new PdfPCell(new Paragraph("Date: " + new java.util.Date()));
outerTable.addCell(cell);

document.add(outerTable);

document.close();
} catch (DocumentException e) {
e.printStackTrace();
}
resp.setContentType("application/pdf");
out.flush();

//---->
18 years ago
Hello again,

but I get the generated PDF page, from iText, as Document object.
How can I forwared the object to the e-mail message to attach the pdf document?

Regards,
Bashar
18 years ago
Hi all,

I need your help with the following case:

I have a servlet that generate a PDF file using iText. I want to attach the generated pdf object to JavaMail 1.4, without storing the pdf on my server.

Please help with this situation or give me links to sites that discuss attaching objects to JavaMail.

Regards,
[ July 19, 2006: Message edited by: Bashar Ayyash ]
18 years ago
Hi guys,

I have a String sentence (for ex. "Welcome back back back home home!!!"), I want to remove the redundancy in the statement ("Welcome back home!")

Is there any method in String, or StringBuffer class help me do that?

Regards,
18 years ago
hi peter and stu, I posted my request to multiple forums to make sure that at least one of them will help me with my request, and peter I already built the forms, servlet and the beans, I'm trying to solve that by my own, anyway I want to tell you one thing that net main goal to make people share knowledge.
[ March 13, 2006: Message edited by: Bashar Ayyash ]