How to attach a file to the mail in jsp

hi.i would like to send mails with in local server with files as attachments.i wrote this code but its not working.please help
<%@ page import="javax.mail.*,javax.mail.internet.*,java.util.Date,java.io.*,java.net.InetAddress,java.sql.*,java.util.Properties,java.net.*,javax.sql.*,javax.activation.*,java.util.*,java.text.*" %>
<%@ page import="java.io.*,java.sql.*,java.net.*,java.util.*,java.text.*" %>
<%
     String Attachfiles1="";
if("Send".equalsIgnoreCase("send"))
try
     String subject="",from="",url = null,to="";
     String mailhost = "local server";
     Properties props = System.getProperties();
String msg_txt="";
     String strStatus="";
String mailer = "MyMailerProgram";
to=request.getParameter("to");
from=request.getParameter("from");
subject=request.getParameter("subject");
msg_txt=request.getParameter("message");
Attachfiles1=request.getParameter("fieldname1");
props.put("mail.smtp.host", mailhost);
Session mailsession = Session.getDefaultInstance(props, null);
Message message = new MimeMessage(mailsession);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
// message.setSubject(subject);
// message.setHeader("X-Mailer", mailer);
// message.setSentDate(new Date());
message.setText(msg_txt);
               // Final message = part1 + part2
               Multipart mp = new MimeMultipart();
               message.setContent(mp);
               // Message part 1 is text - add to multipart
               MimeBodyPart m1 = new MimeBodyPart();
               m1.setContent(msg_txt, "text/plain");
               mp.addBodyPart(m1);
               // Message part 2 is binary (file to send)
               MimeBodyPart m2;
               // Support multiple file send (separated by ";")
               FileDataSource fds = new FileDataSource(Attachfiles1);
                    m2 = new MimeBodyPart();
                    m2.setDataHandler(new DataHandler(fds) );
                    m2.setFileName( new File(Attachfiles1).getName() );
                    mp.addBodyPart(m2);     // add to final message (part 2)
//message.addAttachment(new Attachment(new File(Attachfiles1)));
//BodyPart messageBodyPart = new MimeBodyPart();
//BodyPart messageBodyPart2 = new MimeBodyPart();
//Multipart multipart = new MimeMultipart();
////messageBodyPart = new MimeBodyPart();
//javax.activation.DataSource source = new javax.activation.FileDataSource(Attachfiles1);
//messageBodyPart.setDataHandler(new DataHandler(source));
////messageBodyPart.setFileName(new File(Attachfiles1).getName());
//messageBodyPart2.setText(msg_txt); // set the txt message
//multipart.addBodyPart(messageBodyPart);
//multipart.addBodyPart(messageBodyPart2);
//message.setContent(this.multipart);
Transport.send(message);
out.println("Message Sent");
catch (Exception e)
e.printStackTrace();
%>
<html>
<body>
<div class="frame">
     <form action="Composemailpp.jsp" method="post">
          <b>SelectPosition:</b> <select name="cars" >
<option value="ABAP">ABAP
<option value="JAVA">JAVA
<option value="DOTNET">DOTNET
<option value="SAP">SAP
</select><br><br>
<table border="1" cellpadding="2" cellspacing="2">
<tr><th>
Name<br><input type="text" name="Name"><br>
</th>
<th>
EmailId<br><input type="text" name="EmailId"><br>
</th>
<th>
ContactNumber<br><input type="text" name="ContactNumber"><br>
</th>
<th>
Position<br><input type="text" name="Position"><br>
</th>
</tr>
</table><br>
<b>SelectUser :</b><select name="cars">
<option value="Administrator">Administrator
<option value="User1">User1
<option value="User2">User2
<option value="User3">User3
<option value="User3">User4
</select>
<br>
<b>To :</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="to" size="72"><br>
<b>From :</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="from" size="72"><br>
<b>Subject :</b>&nbsp&nbsp&nbsp<input type="text" name="subject" size="72"><br>
<b>Message:</b><br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<textarea rows="10" cols="50" name="message">
</textarea> <br><br>
<b>AttachedFile:</b>&nbsp<input type="file" name="fieldname1" value="filename" size="50"><br><br>
<!--<b>AttachedFile:</b>&nbsp<input type="file" name="fieldname2" value="filename" size="50"><br><br>
<b>AttachedFile:</b>&nbsp<input type="file" name="fieldname3" value="filename" size="50"><br><br>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="submit" name="attachfiles" value="Attachfiles">
-->
<center>
<input type="submit" name="send" value="Send" >
</center>
</form>
</div>
</body>
</html>

message.setText(msg_txt);Don't do this. You want a multipart message. You want the msg_txt
to be the first part of the multipart, which you do below.
               // Final message = part1 + part2
               Multipart mp = new MimeMultipart();
               message.setContent(mp);
               // Message part 1 is text - add to multipart
               MimeBodyPart m1 = new MimeBodyPart();
               m1.setContent(msg_txt, "text/plain");m1.setText(msg_txt); // would be better
               mp.addBodyPart(m1);
               // Message part 2 is binary (file to send)
               MimeBodyPart m2;
               // Support multiple file send (separated by ";")
FileDataSource fds = new
new FileDataSource(Attachfiles1);
                    m2 = new MimeBodyPart();
                    m2.setDataHandler(new DataHandler(fds) );
m2.setFileName( new File(Attachfiles1).getName() );Since you're using JavaMail 1.4, you can replace much of the above
with simply:
m2.attachFile(Attachfiles1);
But none of the problems above should prevent your code from working.
You do understand, of course, that the name of the file is a filename
on the server, not the client that's running the browser, right?
When you say "its not working", what exactly do you mean?

Similar Messages

  • How to attach a file to the mail

    How to attach a file to the mail

    I know that this can be done when going to any PDF program and push (send as  email)
    This also can done with multiple files or even with separate pages from that PDF file (Many programs can do that, like: PDF expert, Adobe Reader, iBooks, PDF Provider, Documents, etc)
    But what if I begin to wright an email, then I wanted to attach a file (such as PDF, or word, or any file) , FOR BASIC APPLE MAIL IT IS UNAVAILABLE
    You can attach Photo or Video but not PDF or other document
    There are some email programs that can attach files to email such as my.mail (as you can see from the photo)
    But why Apple don't provide such simple service ???

  • How to attach a file to a mail in iPad

    How to attach a file in my mail in iPad

    You cannot. The Attach code in browsers means let user browse file system. You cannot access the file system, therefore the mobile version of Safari doesn't allow it.

  • How to attach input file in the Test Script in SECATT in ECC6 ?

    Hi ,
    How to attach input file in the Test Script in ECC6  in Tcode SECATT ?
    For Testing in SECATT in ECC6, how to attach input file which contains multiple records ?
    Best Regards,
    Padhy

    Hi and Welcome to the Community!
    Since you have balance, and the issue is in your Work domain, you need to work with your server admins, as it's possible they are forbidding (via IT Policy) the ability to do as you desire.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • How to attach two files in the send mail action

    Hi experts
    I want to attach two files in the send mail action . I tried using ; as a separator but it did not work .
    Regards,
    Antonio R . Rubalcaba

    Thanks Jeremy,  
    Yes I am contemplating the another threat .  I still want to send two files because the two files have very distinct type of information .  The first one is operational and the second one is about statistics .  Of course that I can send both type of inforrmation in only one file . I just want to save time to the end user and let him select what infomation he wants to see .
    Thanks and my best wishes for you and your family ,
    Antonio

  • How to attach multiple file in one mail

    Hi,
    I've problems with sending multiple files via Gmail account (Ipad version)  When sending the photo or video, I've to just click the photo and choose send to mail one by one. Any simpler way?  Sometimes i did sent both mpg and jpg but the reciepient didn't see any attachment too
    Anyone can help advise how to attach different file (doc, video, photo) in one mail will be a lot appreciated. Thank you so much

    You can attach multiple pictures to an email on an ipad2. Don't know about original iPad.
    Choose a photo or take a screen shot (hold down home button and button next to volume control at same time--screen shot now will appear in photos).
    Go to photos and edit your picture or screen shot, save it, then hold down on the image and copy it.
    Go to mail, create a new mail and paste it in.
    Save you mail as a draft.
    Go back to photos and select a different photo, copy it, and return to your draft, and paste it in. Repeat if you need to add more.
    Anything that you can take a screen shot or have an photo of can be pasted in one at a time into that draft email.
    If mail gets uncooperative, during this process, then double click on home button and quit multitasking mail, then open up mail again and send your draft. Uncooperative means gets frozen.

  • How to attach a file to a mail using htmldb

    Hi all,
    can u help me how to attach a file in htmldb.
    iam able to send a mail using the inbuilt package but unable to attach a file.
    advance thanks in helping out.

    The APEX_MAIL package doesn't support sending emails with attachments.
    See Send E-Mail with attachment from HTML DB for some alternatives.

  • Attach rar file in the mail

    My company IronPort has limited outgoing mail attachment size to 13MB. Recently, I found that when I send a mail attached with a rar file (10MB), the IronPort has detected the message size is over 13MB. Actually, the message body contains few words and the attachment size is around 10MB.
    I don't understand why when I attach a rar file in the mail. the mail size will be increased around 33%. I also tried sending rar in yahoo mail and got the same results. Do anybody know the reason??

    How can I also strip the attachment if the executable is compressed (.zip or .rar)?
    This is a complicated question. A message filter can peek inside archive files, but not compressed solitary files. In other words, a .exe file inside a ZIP archive can be detected. But a .exe file that has been gzipped (file.exe.gz), will not be detected.
    The full explanation is in the "Policy Enforcement" chapter of the Advanced User Guide.

  • How to attach a file in the utl_mail utility in oracle 10.2.0

    hi,
    where is the default file destination to attach a file in the utl_mail utility in oracle 10g. i have to send an attachment..
    regards,
    Deepak
    Edited by: Deepak_DBA on Nov 4, 2009 3:10 PM

    HI,
    I have succesfully created utl_mail and send mail.. but could not able to attach a file in that mail..
    i have used the procedure given below..
    DECLARE
    rfile VARCHAR2(255);
    BEGIN
    UTL_MAIL.send_attach_varchar2(sender =>'[email protected]',recipients =>'[email protected]',subject =>'Test new Mail',message => 'Oracle World',mime_type => 'text; charset=us-ascii',priority => 3,attachment => rfile,att_inline => TRUE,att_mime_type=> 'text/plain; charset=us-ascii',att_filename => 'i:\session.txt');
    END;
    regards,
    Deepak

  • How to attach PDF file along with mail from SAP to external

    Hi Experts,
          Whenever I am creating PO I should get that creation information ( PO is created & PO no is ‘XXX’….) in the form of PDF file & I have to send this PDF file through mail to external. I have to do all this in one development…How can I proceed …Help me..
    Thanks

    Check this Code>>>>>>>>>>>
          FORM MAIL_OBJECT                                              *
    Compiled: Thomas, Satyam Computers Services Ltd.
          This routine receives OTF data. OTF data is converted to PDF
          format and send to the Partner's email address
    FORM mail_object TABLES otf_data STRUCTURE itcoo .
      DATA: pdf_size TYPE i,                             " PDF Size
            pdf_itab_size TYPE i,                        " Attachment size
            mailtxt_size TYPE i,                         " Text in mail size
            l_vbeln LIKE vbdka-vbeln.                    " Order Doc
      DATA:
      it_mailtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,    " Mail Text
      it_pdf TYPE TABLE OF tline WITH HEADER LINE,           " OTF output
      it_mailpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, " Dist details
      it_mailhead LIKE solisti1   OCCURS  1 WITH HEADER LINE," Header data
      it_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,   " Rec List
      it_pdfdata LIKE solix OCCURS 0 WITH HEADER LINE.  " Attachment data
      DATA: it_doc_att LIKE sodocchgi1.                 " Attri of new doc
      DATA: BEGIN OF it_pdfout OCCURS 0,                " PDF in 255 length
               tline TYPE char255,
            END OF it_pdfout.
    Sales doc and Customer
      DATA: BEGIN OF i_vbeln OCCURS 0,
              vbeln LIKE vbpa-vbeln,       " Sales Document
              adrnr LIKE vbpa-adrnr,       " Customer
            END   OF i_vbeln.
    Sender Address no and SMTP address
      DATA: BEGIN OF i_addrs OCCURS 0,
              addrnumber LIKE adr6-smtp_addr,
              smtp_addr  LIKE adr6-smtp_addr,
            END   OF i_addrs.
    Convert OTF to PDF
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format       = 'PDF'
        IMPORTING
          bin_filesize = pdf_size
        TABLES
          otf          = otf_data
          lines        = it_pdf.
    Make each line 255 characters
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        TABLES
          content_in  = it_pdf
          content_out = it_pdfout.
    Create the PDF File
      CLEAR it_pdfdata.
      REFRESH it_pdfdata.
    it_pdfdata[] = it_pdfout[].
      LOOP AT it_pdfout.
        MOVE it_pdfout-tline TO it_pdfdata-line.
        APPEND it_pdfdata.
        CLEAR it_pdfdata.
      ENDLOOP.
      DESCRIBE TABLE it_pdfdata LINES pdf_itab_size.
    Text in the mail.
      it_mailtxt-line  = 'ORDER ACKNOWLEDGEMENT'.
      APPEND it_mailtxt.
      it_mailtxt-line  = ' This is a test mail-Thomas, Line Number--1'.
      APPEND it_mailtxt.
      it_mailtxt-line = ' This is a test mail-Thomas, Line Number--2' &
                        ' This is a test mail-Thomas, Line Number--2'.
      APPEND it_mailtxt.
      it_mailtxt-line = ' This is a test mail-Thomas, Line Number--3' &
                        ' This is a test mail-Thomas, Line Number--3' &
                        ' This is a test mail-Thomas, Line Number--3'.
      APPEND it_mailtxt.
      it_mailtxt-line = ' This is a test mail,  Line Number--4' &
                        ' This is a test mail,  Line Number--4' &
                        ' This is a test mail,  Line Number--4' &
                        ' This is a test mail,  Line Number--4'.
      APPEND it_mailtxt.
      it_mailtxt-line = ' This is a test mail,  Line Number--5' &
                        ' This is a test mail,  Line Number--5' &
                        ' This is a test mail,  Line Number--5' &
                        ' This is a test mail,  Line Number--5' &
                        ' This is a test mail,  Line Number--5'.
      APPEND it_mailtxt.
      DESCRIBE TABLE it_mailtxt LINES mailtxt_size.
    Document Number for Output
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          input  = vbdka-vbeln
        IMPORTING
          output = l_vbeln.
    Attributes of new doc
      CONCATENATE 'Order' space 'Acknowledgement' space l_vbeln
                  INTO it_doc_att-obj_descr SEPARATED BY space.
      it_doc_att-sensitivty = 'F'.
      it_doc_att-doc_size   = mailtxt_size * 255.
    Create Pack to text in mail body.
      CLEAR it_mailpack-transf_bin.
      it_mailpack-head_start   = 1.
      it_mailpack-head_num     = 0.
      it_mailpack-body_start   = 1.
      it_mailpack-body_num     = mailtxt_size.
      it_mailpack-doc_type     = 'RAW'.
      APPEND it_mailpack.
    Create Pack to PDF Attach.
      it_mailpack-transf_bin   = 'X'.
      it_mailpack-head_start   = 1.
      it_mailpack-head_num     = 1.
      it_mailpack-body_start   = 1.
      it_mailpack-body_num     = pdf_itab_size.
      it_mailpack-doc_type     = 'PDF'.
      CONCATENATE l_vbeln '.pdf' INTO it_mailpack-obj_name.
      CONCATENATE 'Order Ack' space l_vbeln INTO it_mailpack-obj_descr.
      it_mailpack-doc_size     = pdf_itab_size * 255.
      APPEND it_mailpack.
    *Get email addresses based on Sales document.
      SELECT vbeln adrnr INTO TABLE i_vbeln
             FROM vbpa
             WHERE vbeln = vbdka-vbeln AND
                   parvw = nast-parvw.
      IF NOT i_vbeln[] IS INITIAL.
        SELECT addrnumber smtp_addr INTO TABLE i_addrs
               FROM adr6 FOR ALL ENTRIES IN i_vbeln
               WHERE addrnumber =  i_vbeln-adrnr AND
                     smtp_addr NE space.
      ENDIF.
      IF i_addrs[] IS NOT INITIAL.
        LOOP AT i_addrs.
          it_reclist-receiver   = i_addrs-smtp_addr.
          it_reclist-express    = 'X'.
          it_reclist-rec_type   = 'U'.
          it_reclist-notif_del  = 'X'. " request delivery notification
          it_reclist-notif_ndel = 'X'. " request not delivered notification
          APPEND it_reclist.
          CLEAR: i_addrs.
        ENDLOOP.
      ENDIF.
    Call FM to send email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = it_doc_att
          put_in_outbox              = 'X'
        TABLES
          packing_list               = it_mailpack
          object_header              = it_mailhead
          contents_txt               = it_mailtxt
          contents_hex               = it_pdfdata
          receivers                  = it_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          document_type_not_exist    = 3
          operation_no_authorizationfiltered= 4
          parameter_error            = 5
          x_error                    = 6
          enqueue_error              = 7
          OTHERS                     = 8.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " MAIL_OBJECT
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    -Mohan.
    *Reward if helpful**

  • How to attach HLP file with the existing forms

    We have FORMS 5.0 application running. We have developed .HLP and .CNT files using ROBOHELP utility. I would like to attach the help file to the existing form. I want to use the registry to set the help file path so that I won't hardcode the path. I tried
    using WINHLP32.exe file using the HOST command. This need path settings in the machine. Does any body know other methods instead of using HOST command.
    Thanks in advance.
    Bye
    Meenakshi Sundaram Ganesh

    You could use the d2kwutil.pll and execute the Win_api_shell.Winhelp procedure

  • How to send multiple attachments with the mail in jsp

    hi.I wrote a code to send mail.but i need to send mail with multiple attachments.when i run this code iam able to send message but not files.i want to send files as attachments with the message.please help me.
    <%@ page import="javax.mail.*,javax.mail.internet.*,java.util.Date,java.io.*,java.net.InetAddress,java.sql.*,java.util.Properties,java.net.*,javax.sql.*,javax.activation.*,java.util.*,java.text.*" %>
    <%@ page import="java.io.*,java.sql.*,java.net.*,java.util.*,java.text.*" %>
    <%
         String Attachfiles1="";
         String Attachfiles2="";
    String Attachfiles3="";
    if("Send".equalsIgnoreCase("send"))
    try
    String subject="",from="",url = null,to="";
    String mailhost = "localhost";
    Properties props = System.getProperties();
    String msg_txt="";
    String strStatus="";
    String mailer = "MyMailerProgram";
    to=request.getParameter("to");
    from=request.getParameter("from");
    subject=request.getParameter("subject");
    msg_txt=request.getParameter("message");
    props.put("mail.smtp.host", mailhost);
    Session mailsession = Session.getDefaultInstance(props, null);
    Message message = new MimeMessage(mailsession);
    message.setFrom(new InternetAddress(from));
    message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
    message.setSubject(subject);
    message.setHeader("X-Mailer", mailer);
    message.setSentDate(new Date());
    message.setText(msg_txt);
    BodyPart messageBodyPart = new MimeBodyPart();
    BodyPart messageBodyPart2 = new MimeBodyPart();
    Multipart multipart = new MimeMultipart(); // to add many part to your messge
    messageBodyPart = new MimeBodyPart();
    javax.activation.DataSource source = new javax.activation.FileDataSource("path of the file");
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName("file_name");
    messageBodyPart2.setText("message"); // set the txt message
    multipart.addBodyPart(messageBodyPart);
    multipart.addBodyPart(messageBodyPart2);
    Transport.send(message);
    out.println("Message Sent");
    catch (Exception e)
    e.printStackTrace();
    if("Attachfiles".equalsIgnoreCase("attachfiles"))
    Attachfiles1=request.getParameter("fieldname1");
    Attachfiles2=request.getParameter("fieldname2");
    Attachfiles3=request.getParameter("fieldname3");
    %>
    <html>
    <body>
    <div class="frame">
    <form action="Composemail.jsp" method="post">
    <b>SelectPosition:</b> <select name="cars" >
    <option value="ABAP">ABAP
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select><br><br>
    <table border="1" cellpadding="2" cellspacing="2">
    <tr><th>Name</th>
    <th>EmailId</th>
    <th>ContactNumber</th>
    <th>Position</th>
    </tr>
    <tr>
    <td>
    </td>
    </tr>
    </table><br>
    <b>SelectUser :</b><select name="cars">
    <option value="Administrator">Administrator
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select>
    <br>
    <b>To :</b>�����������<input type="text" name="to" size="72"><br>
    <b>From :</b>�������<input type="text" name="from" size="72"><br>
    <b>Subject :</b>���<input type="text" name="subject" size="72"><br>
    <%=Attachfiles1%><br><%=Attachfiles2%><br><%=Attachfiles3%><br><br>
    <b>Message:</b><br>
    ������������<textarea rows="10" cols="50" name="message">
    </textarea> <br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname1" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname2" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>�<input type="file" name="fieldname3" value="filename" size="50"><br><br>
    ������������<input type="submit" name="attachfiles" value="Attachfiles">
    <center>
    <input type="submit" name="send" value="Send" >
    </center>
    </form>
    </div>
    </body>
    </html>

    Most likely you're not specifying the path of a file on the server machine.

  • How to attach XML file in the response of Web Services

    Hi
    I am new to the WEB SERVICE. this my requirement.
    I need to make a class file a web service. and i need to get data from the data base and attach it in the response. I need to use SOAP MEssaging for this. so how to call the service from the JSP and how to get the data from the response,Before that which technology i need to use for this requirement. Plz let me know how to accomplish this task. I have gone thur lot of tech stuff and i am confused a lot, what to use and how to use. Will any one help me out.
    Thanks
    Vidya

    Hey VP, thanks for replyng.
    I have read the codes from a book and havesome code for client. The server side is yet to be done....but I have problems in compiling them as I am Unable to import javax.xml.soap.*;
    This is basically a request to the Server asking it to find the match of the word "Mickey" from the XMLfile at the server...JAXRPC is involved(I Presume:) There are some supporting files.........hey But it doesn't compile only here. Hope it does in yrs
    *******The client..........**********
    * Client
    package com.aby.jwsdp.soap.client;//the package
    import javax.xml.messaging.URLEndpoint;
    import javax.xml.soap.SOAPConnectionFactory;
    import javax.xml.soap.SOAPConnection;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.Source;
    import javax.xml.transform.stream.StreamResult;
    import com.aby.jwsdp.soap.client.Fault;//supporting file
    import com.aby.jwsdp.soap.client.RequestMessage;//supporting file
    public class Client {
         static final string SERVICE_ENDPOINT="http://localhost:8080/chap/servlet/chap.RecieveServlet";
         public static void main(String args[]) {
              if(1!=args.length) {
                   System.err.println("Usage: java "+"com.aby.jwsdp.soap.client.Client <name>");
              } else {
                   new Client(args[0]);
         public Client(String name) {
              try{
                   URLEndpoint endpoint = new URLEndpoint(SERVICE_ENDPOINT);
                   SOAPConnectionFactory scf=SOAPConnectionFactory.newInstance();
                   SOAPConnection connection = scf.createConnection();
                   RequestMessage reqMsg = new RequestMessage();
                   reqMsg.setName(name);
                   SOAPMessage replySOAP = connection.call(reqMsq.getMessage(),endpoint);
                   if(Fault.hasFault(replySOAP)) {
                        Fault fault = new Fault(replySOAP);
                        System.err.println("Recieved SOAP Fault");
                        System.err.println("Fault Code: "+fault.getFaultCode());
                        System.err.println("Fault string: "+fault.getFaultString());
                        System.err.println("Fault detail: "+fault.getFaultDetail());
                   }else {
                        ResponseMessage respMsg = new ResponseMessage(replySOAP);
                        String responseValue = null;
                        try{
                             responseValue = respMsg.getValue();
                             System.out.println("Response: "+responseValue);
                        }catch(SchemaException e) {
                             System.err.println("Parsing error");
                   connection.close();
              }catch(EXception e) {
                   System.err.println(e/toString());
    /*@author Aby
    *Fault.java
    package com.aby.jwsdp.soap.client;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPPart;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPFault;
    import javax.xml.soap.SOAPException;
    import javax.xml.soap.Detail;
    import javax.xml.soap.DetailEntry;
    import java.util.Iterator;
    public class Fault {
         protected SOAPFault soapFault;
         public Fault(SOAPMessage msg) throws SOAPException {
              SOAPPart soapPart = msg.getSOAPPart();
              SOAPEnvelope envelope = soapPart.getEnvelope();
              SOAPBody soapBody = envelope.getBody();
              soapFault = soapBody.getFault();
         public static boolean hasFault(SOAPMessage msg) throws SOAPException {
              SOAPPart soapPart = msg.getSOAPPart();
              SOAPEnvelope envelop = soapPart.getEnvelop();
              SOAPBody soapBody = envelop.getBody();
              return soapBody.hasFault();
         public String getFault() {
              return soapFault.getFaultCode();
         public String getFaultString() {
              return soapFault.getFaultString();
         public String getFaultDetail() {
              String ret = null;
              Detail detail = soapFault.getDetail();
              if(null!=detail) {
                   Iterator it = detail.getDetailEntries();
                   if(it.hasNext()) {
                        DetailEntry detEntry = (DetailEntry)it.next();
                   ret = detEntry.getValue();
              return ret;
    * RequestMessage.java
    package com.aby.jwsdp.soap.client;
    import com.aby.jwsdp.soap.client.Client;
    import javax.xml.soap.MessageFactory;
    import javax.xml.soap.SOAPMessage;
    import javax.xml.soap.SOAPPart;
    import javax.xml.soap.SOAPEnvelope;
    import javax.xml.soap.SOAPBody;
    import javax.xml.soap.SOAPElement;
    import javax.xml.soap.SOAPException;
    public class RequestMessage {
         protected SOAPMessage soapMessage = null;
         public RequestMessage()
         throws SOAPException {
              MessageFactory mf = MessageFactory.newInstance();
              soapMessage = mf.createMessage();
         public void setName(String name)
         throws SOAPException {
              SOAPPart soapPart = soapMessage.getSOAPPart();
              SOAPEnvelope envelope = soapPart.getEnvelope();
              SOAPBody body = envelope.getBody();
              SOAPElement requestElement;
              requestElement = body.addChildElement(envelope.createName("GetValueByName","myns","www.syngress.com/JWSDP/soap-example"));
              SOAPElement paramElement;
              paramElement = requestElement.addChildElement("name");
              paramElement.addTextNode(name);
         public SOAPMessage getMessage() {
              return soapMessage;
    check this out then we will see

  • How to attach a file fin the middle tier in the workflow notification

    My requirement
    1) File is there in the middle tier (file name : invoice_99.pdf )
    2) From workflow notification I need to read that file (invoice_99.pdf) and
    open it from the notification when user click on it
    can you please let me know is there any way to handle this

    Thiru,
    This is not the right forum for this.
    Btw, I have done exactly same requirement several times and it's easy to do.
    1)Create a Document Attribute and specify to attach it to the notif msg.
    2)Create a PL/SQL function activity in workflow
    3)In the PL/SQL proc, Load the file using dbms_lob into a LOB and set the attribute using
    wf_engine.SetItemAttrText(itemtype      => itemType
    ,itemkey      => itemkey
    ,aname      => 'SRQ_REPORT'
    ,avalue           => 'PLSQLCLOB:xxx_gbl_wf.get_pdf_quote/'||v_report_request_id||':'||v_qot_number);
    Hope this helps
    Srini

  • How do I attach a file to a mail message with my new iPhone?

    My daughter wants to know how to attach a file to a mail message and even send a file from iCloud to someone via iPhone mail.
    How do we do that?
    Thanks,
    Rookie

    Firefox doesn't do email, it's a web browser.
    If you are using Firefox to access web mail, you need to seek support from your service provider or a forum for that service.
    If your problem is with Thunderbird, see this forum for support.
    http://www.mozillamessaging.com/en-US/support/https://addons.mozilla.org/en-US/firefox/browse/type:3https://addons.mozilla.org/en-US/firefox/browse/type:3
    or this one
    http://forums.mozillazine.org/viewforum.php?f=39

Maybe you are looking for