Converting emails to servlet requests; servlet responses to emails

Hello,
I had asked this question in the Servlet forum. They directed me to here.
I've some servlet applications that posted by HTML forms with file attachements and other HTML fields.
I want to add email support to my servlets. So, users should be able post and recieve their data by emails.
But, I don't want to add email handling tasks to the current servlet applications. I need a middleware application between end users and my servlets that converts emails to servlet requests, and servlet responses to emails.
Here are the steps:
1- End user sends email with attachments.
2- Emailed data is converted to servlet request by a middleware application.
3- Servlet request is processed by my current servlets.
4- Servlet response is sent to middleware application.
5- Middleware application emails servlet reponse to end user as email.
If I can do that, I will not have to add emailing codes to my current servlets. do you know a product doing that ? Or, can you give me a direction ?
thanks...

Have you looked into JMS?

Similar Messages

  • Send email from j2me through servlet

    Hi people,
    i hope you can help me because i am new in network programming.
    I am trying to send email from j2me to googlemail account I have 2 classes EmailMidlet (which has been tested with wireless Toolkit 2.5.2 and it works) and the second class is the servlet-class named EmailServlet:
    when i call the EmailServlet, i get on the console:
    Server: 220 mx.google.com ESMTP g28sm19313024fkg.21
    Server: 250 mx.google.com at your service
    this is the code of my EmailServlet
    import java.io.*;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.text.*;
    import java.util.Date;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class EmailServlet extends HttpServlet {
       public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws IOException, ServletException {
          System.out.println("____emailservlet.doPost");
          response.setContentType("text/plain");
          PrintWriter out = response.getWriter();
          System.out.println("______________________________");
          out.println();
          String to = request.getParameter("to");
          System.out.println("____________________________to" + to);
          String subject = request.getParameter("subject");
          String msg = request.getParameter("msg");
          // construct an instance of EmailSender
          System.out.println("servlet_to" + to);
          send("[email protected]", to, subject, msg);
          out.println("mail sent....");
       public void send(String from, String to, String subject, String msg) {
          Socket smtpSocket = null;
          DataOutputStream os = null;
          DataInputStream is = null;
          try {
             smtpSocket = new Socket("smtp.googlemail.com", 25);
             os = new DataOutputStream(smtpSocket.getOutputStream());
             is = new DataInputStream(smtpSocket.getInputStream());
          } catch (UnknownHostException e) {
             System.err.println("Don't know about host: hostname");
          } catch (IOException e) {
             System.err
                   .println("Couldn't get I/O for the connection to: hostname");
          if (smtpSocket != null && os != null && is != null) {
             try {
                os.writeBytes("HELO there" + "\r\n");
                os.writeBytes("MAIL FROM: " + from + "\r\n");
                os.writeBytes("RCPT TO: " + to + "\r\n");
                os.writeBytes("DATA\r\n");
                os.writeBytes("Date: " + new Date() + "\r\n"); // stamp the msg
                                                    // with date
                os.writeBytes("From: " + from + "\r\n");
                os.writeBytes("To: " + to + "\r\n");
                os.writeBytes("Subject: " + subject + "\r\n");
                os.writeBytes(msg + "\r\n"); // message body
                os.writeBytes(".\r\n");
                os.writeBytes("QUIT\r\n");
                // debugging
                String responseLine;
                while ((responseLine = is.readLine()) != null) {
                   System.out.println("Server: " + responseLine);
                   if (responseLine.indexOf("delivery") != -1) {
                      break;
                os.close();
                is.close();
                smtpSocket.close();
             } catch (UnknownHostException e) {
                System.err.println("Trying to connect to unknown host: " + e);
             } catch (IOException e) {
                System.err.println("IOException: " + e);
       } 1.when i print "to" in EmailServlet also:
      String to = request.getParameter("to");
          System.out.println("____________________________to" + to);  it show null on the console :confused:
    2. ist this right in case of googlemail.com?
      smtpSocket = new Socket("smtp.googlemail.com", 25);  I would be very grateful if somebody can help me.

    jackofall
    Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
    I'm locking this thread now.
    db

  • Problem sending email using javamail in servlet

    I try this code and make some changes of my own http://forums.sun.com/thread.jspa?threadID=695781.
    When i run the program the confirmtaion shows that the mail has been sent, but when i check in my inbox there's no the message. I'm using gmail and need to authenticate the username and password. I guess the error caused in the servlet.
    Here's the code for my servlet :
    import java.io.*;
    import java.util.Properties;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.mail.internet.*;
    import javax.mail.*;
    public class ServletEx extends HttpServlet {
       public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws IOException, ServletException {
          System.out.println("____emailservlet.doPost");
          response.setContentType("text/plain");
          PrintWriter out = response.getWriter();
          System.out.println("______________________________");
          out.println();
          String to = request.getParameter("to");
          System.out.println("____________________________to" + to);
          String subject = request.getParameter("subject");
          String msg = request.getParameter("msg");
          // construct an instance of EmailSender
          System.out.println("servlet_to" + to);
          send(username, to, subject, msg);
          //send("[email protected]", to, subject, msg);
          out.println("mail sent....");
            String username = "[email protected]";
            String password = "my_password";
            String smtp = "smtp.gmail.com";
            String port = "587";
       public void send(String username, String to, String subject, String msg) {
            Properties props = new Properties();
            props.put("mail.smtp.user", username);
            props.put("mail.smtp.host", smtp);
            props.put("mail.smtp.port", port);
            props.put("mail.smtp.starttls.enable","true"); // just in case, but not currently necessary, oddly enough
            props.put("mail.smtp.auth", "true");
            //props.put("mail.smtp.debug", "true");
            props.put("mail.smtp.socketFactory.port", port);
            props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
            props.put("mail.smtp.socketFactory.fallback", "false");
            SecurityManager security = System.getSecurityManager();
            try
                Authenticator auth = new SMTPAuthenticator();
                Session session = Session.getInstance(props, auth);
                //session.setDebug(true);
                MimeMessage message = new MimeMessage(session);
                message.setText(msg);
                message.setSubject(subject);
                message.setFrom(new InternetAddress(username));
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
                Transport.send(message);
            catch (Exception mex)
                mex.printStackTrace();
       public class SMTPAuthenticator extends javax.mail.Authenticator {
            public PasswordAuthentication getPasswordAuthentication(String username, String password)
                return new PasswordAuthentication(username, password);
    }Actually it's been a long time for me to develope this program, especially with the authenticate smtp. Any help would be very appreciated :)

    Accordingly to your stackTrace, I think that you miss some utility jar from Geronimo app. server.
    As you are using Application server that is J2EE compliant, so there is an own JavaMail implementation embeded and used by the Server. To fix this problem you have to find and add to your calsspath a jar-file that contains Base64EncoderStream.class

  • Servlet request terminated with IOException:java.io.IOException: There is no process to read data written to a pipe.

    Hi,
    I am getting this following error. Could anyone please throw some light.
    Thanks
    Nilesh
    <HTTP> Servlet request terminated with IOException:
    java.io.IOException: There is no process to read data written to a pipe.
         at java.net.SocketOutputStream.socketWrite(Native Method)
         at java.net.SocketOutputStream.write(SocketOutputStream.java(Compiled Code))
         at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java(Compiled
    Code))
         at weblogic.servlet.internal.ResponseHeaders.writeHeaders(ResponseHeaders.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletResponseImpl.writeHeaders(ServletResponseImpl.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamImpl.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletOutputStreamImpl.finish(ServletOutputStreamImpl.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java(Compiled
    Code))
         at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java(Compiled
    Code))
         at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java(Compiled
    Code))
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)

    I forgot to mention.
    I am using Weblogic 5.1 with SP 9
    Nilesh
    "Nilesh Shah" <[email protected]> wrote:
    >
    Hi,
    I am getting this following error. Could anyone please throw some light.
    Thanks
    Nilesh
    <HTTP> Servlet request terminated with IOException:
    java.io.IOException: There is no process to read data written to a pipe.
         at java.net.SocketOutputStream.socketWrite(Native Method)
         at java.net.SocketOutputStream.write(SocketOutputStream.java(Compiled
    Code))
         at weblogic.servlet.internal.ChunkUtils.writeChunks(ChunkUtils.java(Compiled
    Code))
         at weblogic.servlet.internal.ResponseHeaders.writeHeaders(ResponseHeaders.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletResponseImpl.writeHeaders(ServletResponseImpl.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletOutputStreamImpl.flush(ServletOutputStreamImpl.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletOutputStreamImpl.finish(ServletOutputStreamImpl.java(Compiled
    Code))
         at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java(Compiled
    Code))
         at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java(Compiled
    Code))
         at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java(Compiled
    Code))
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)

  • Limit of Weblogic for servlet requests

              Hi,
              Could someone tell me what is the limit on the number of servlet requests per
              second a weblogic server
              can handle.. We are facing some performance issue.. Would like to know the limit
              that WLS server can process
              at a time.
              Thanks in advance,
              rgds, rams
              

    Thanks Robert - I had the same results on 4-way E420 (and slightly less for
              session-less JSP). Don't you think it can be potentially useful to have some
              'baseline' results to be available for some most popular hardware/JVM configurations ?
              (Of course, these numbers have nothing to do with an actual application performance, but
              they are useful in establishing the 'upper limit' - something like HelloWorld servlet,
              HelloWorld JSP with session=false, HelloWorld JSP with sessions enabled).
              Robert Patrick <[email protected]> wrote:
              > Hmm... This is a loaded question. It comes down to what type of hardware is the
              > server running on, what is the servlet doing, what does your network look like, and
              > on and on. I can tell you that with a version of WLS 5.1, I was able to get approx.
              > 1100 to 1200 "page views per second" from a HelloWorld servlet running on a 4-way
              > Sun E420 using Mercury's LoadRunner software running on multiple NT machines. For
              > this hardware configuration and server version, I would use this as the upper limit
              > for a single instance...
              > Rams wrote:
              >> Hi,
              >>
              >> Could someone tell me what is the limit on the number of servlet requests per
              >> second a weblogic server
              >> can handle.. We are facing some performance issue.. Would like to know the limit
              >> that WLS server can process
              >> at a time.
              >>
              >> Thanks in advance,
              >>
              >> rgds, rams
              Dimitri
              

  • Cannot process an HTTP request to servlet [Faces Servlet] in [wcb] web application

    Hi All
    l am working on a Wcem 3.0 with Trex with ERP and WAS 7.3.
    When I logon to http://<host>:<port>/wcb/index.html url I am able to see wcbuilder_erp & wcbuilder_erp_ume application ids.
    But suddenly I am getting The website cannot display the page error message when I access the above mentioned URL.
    When I verify the developer log trace it showing as 500 Internal sever error issue.[EXCEPTION] java.lang.VerifyError: Bad return type
    In defaultTrace.trc file it is showing as Cannot process an HTTP request to servlet [Faces Servlet] in [wcb] web application exception.
    09 10 18:08:56:098#+0530#Error#com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl#
    com.sap.ASJ.web.000137#WEC-APP-BF#sap.com/wec~comm~wcb~leanapp#C0000A229CA7094A0000000000001188#2392750000000004#sap.com/wec~comm~wcb~leanapp#com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl#Guest#0##CFAFBF4C38E411E4B4750000002482AE#ffbcbcdd38e611e49d020000002482ae#ffbcbcdd38e611e49d020000002482ae#0#Thread[HTTP Worker [@455349581],5,Dedicated_Application_Thread]#Plain##
    Cannot process an HTTP request to servlet [Faces Servlet] in [wcb] web application.
    [EXCEPTION] java.lang.VerifyError: Bad return type
    Exception Details:
    Location: com/sap/wec/tc/core/runtime/jsf/resource/WecExternalContextFactory.getExternalContext(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljavax/faces/context/ExternalContext; @17: areturn
    Reason: Type 'com/sap/wec/tc/core/runtime/jsf/resource/WecExternalContext' (current frame, stack[0]) is not assignable to 'javax/faces/context/ExternalContext' (from method signature)
    Current Frame:
        locals: { 'com/sap/wec/tc/core/runtime/jsf/resource/WecExternalContextFactory', 'java/lang/Object', 'java/lang/Object', 'java/lang/Object' }
        stack: { 'com/sap/wec/tc/core/runtime/jsf/resource/WecExternalContext' }
      Bytecode:
        0000000: bb00 0359 2ab6 0004 2b2c 2db6 0005 b700
        0000010: 06b0                                
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2446)
        at java.lang.Class.getConstructor0(Class.java:2756)
        at java.lang.Class.getConstructor(Class.java:1693)
    Any help?
    Regards
    Rami Reddy

    Hi Steffen,
    Thanks for promt response.
    But when I checked with Basis team as of now there are not yet configured TREX, only WCEM components has been configured in WAS 7.3. When they are configuring WCEM components HTTPS protocol not configured.
    But for past 2 weeks I am able to see the below screen using http://<host>:<port>/wcb/index.html url.
    But now I am getting The website cannot display the page error.
    Please clarify me if anything is wrong from my side. And also pl let us know which configurations I have to check for fixing the issue.
    Regards,
    Rami Reddy

  • Call methods (which are in the servlet) in my response page

    Hello !
    I want to call methods which are in the servlet ( its name is ServletRecap) BUT the call is made in the response page which is generated by the servlet ServletRecap !
    I just want to allow the user to update his choice in the response page.
    example: i choice A in the initial form but i change my mind and now i want to choice B in the response page : the choice have to be update in the database.
    the insertion in the DB is made by a method in the servlet : so i have to recall the method in the response page!
    Please, anybody have an idea ?
    my servlet :
    public class ServletRecap extends HttpServlet {
        // param�tres d'instance
        private String urlErreurs = null;
        private ArrayList erreursInitialisation = new ArrayList<String>();
        private String[] param�tres = {"urlFormulaire", "urlReponse", "urlControleur", "lienRetourFormulaire"};
        private Map params = new HashMap<String, String>();
        // init
        @SuppressWarnings("unchecked")
        public void init() throws ServletException {
            // on r�cup�re les param�tres d'initialisation de la servlet
            ServletConfig config = getServletConfig();
            // on traite les autres param�tres d'initialisation
            String valeur = null;
            for (int i = 0; i < param�tres.length; i++) {
            // valeur du param�tre
                valeur = config.getInitParameter(param�tres);
    // param�tre pr�sent ?
    if (valeur == null) {
    // on note l'erreur
    erreursInitialisation.add("Le param�tre [" + param�tres[i] + "] n'a pas �t� initialis�");
    } else {
    // on m�morise la valeur du param�tre
    params.put(param�tres[i], valeur);
    // l'url de la vue [erreurs] a un traitement particulier
    urlErreurs = config.getInitParameter("urlErreurs");
    if (urlErreurs == null) {
    throw new ServletException(
    "Le param�tre [urlErreurs] n'a pas �t� initialis�");
    @SuppressWarnings("unchecked")
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    // on v�rifie comment s'est pass�e l'initialisation de la servlet
    if (erreursInitialisation.size() != 0) {
    // on passe la main � la page d'erreurs
    request.setAttribute("erreurs", erreursInitialisation);
    request.setAttribute("lienRetourFormulaire", "");
    getServletContext().getRequestDispatcher(urlErreurs).forward(
    request, response);
    // fin
    return;
    // on r�cup�re la m�thode d'envoi de la requ�te
    String m�thode = request.getMethod().toLowerCase();
    // on r�cup�re l'action � ex�cuter
    String action = request.getParameter("action");
    // action ?
    if (action == null) {
    action = "init";
    // ex�cution action
    if (m�thode.equals("get") && action.equals("init")) {
    // d�marrage application
    doInit(request, response);
    return;
    if (m�thode.equals("post") && action.equals("validationFormulaire")) {
    // validation du formulaire de saisie
    doValidationFormulaire(request, response);
    return;
    if (m�thode.equals("post") && action.equals("enregistrementFormulaire")) {
    // enregistrement du formulaire de saisie
    doEnregistrementFormulaire(request, response);
    return;
    if (m�thode.equals("post") && action.equals("retourFormulaire")) {
    // retour au formulaire de saisie
    doRetourFormulaire(request, response);
    return;
    // autres cas
    doInit(request, response);
    // validation du formulaire
    void doValidationFormulaire(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    // on r�cup�re les param�tres
    String nomCentre = (String) request.getParameter("nomCentre");
    String idCentre = (String) request.getParameter("idCentre");
    String nomPreleveur = (String) request.getParameter("nomPreleveur");
    String datePrelev = (String) request.getParameter("datePrelev");
    String numFinFiche = (String) request.getParameter("numFinFiche");
    // qu'on m�morise dans la session
    HttpSession session = request.getSession(true);
    session.setAttribute("nomCentre", nomCentre);
    session.setAttribute("idCentre", idCentre);
    session.setAttribute("nomPreleveur", nomPreleveur);
    session.setAttribute("datePrelev", datePrelev);
    session.setAttribute("numFinFiche", numFinFiche);
    // v�rification des param�tres
    ArrayList<String> erreursAppel = new ArrayList<String>();
    // le nom doit �tre non vide
    nomCentre = nomCentre.trim();
    idCentre = idCentre.trim();
    nomPreleveur = nomPreleveur.trim();
    datePrelev = datePrelev.trim();
    numFinFiche = numFinFiche.trim();
    if (nomCentre.equals("")) {
    erreursAppel.add("Le champ [nomCentre] n'a pas �t� rempli");
    if (idCentre.equals("")) {
    erreursAppel.add("Le champ [idCentre] n'a pas �t� rempli");
    if (nomPreleveur.equals("")) {
    erreursAppel.add("Le champ [nomPreleveur] n'a pas �t� rempli");
    if (datePrelev.equals("")) {
    erreursAppel.add("Le champ [datePrelev] n'a pas �t� rempli");
    if (!numFinFiche.matches("^\\s*\\d+\\s*$")) {
    erreursAppel.add("Le champ [numFinFiche] est erron�");
    // des erreurs dans les param�tres ?
    if (erreursAppel.size() != 0) {
    // on envoie la page d'erreurs
    request.setAttribute("erreurs", erreursAppel);
    request.setAttribute("lienRetourFormulaire", (String) params.get("lienRetourFormulaire"));
    getServletContext().getRequestDispatcher(urlErreurs).forward(
    request, response);
    return;
    // les param�tres sont corrects - on envoie la page r�ponse
    request.setAttribute("nomCentre",nomCentre);
    request.setAttribute("idCentre",idCentre);
    request.setAttribute("nomPreleveur",nomPreleveur);
    request.setAttribute("datePrelev",datePrelev);
    request.setAttribute("numFinFiche",numFinFiche);
              request.setAttribute("lienRetourFormulaire", (String) params.get("lienRetourFormulaire"));
    getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(request,
    response);
    return;
    //enregistre dans la base de donn�e les variables
    void doEnregistrementFormulaire(HttpServletRequest request, HttpServletResponse response) throws
    ServletException, IOException {
         String nomCentre = (String) request.getParameter("nomCentre");
    String idCentre = (String) request.getParameter("idCentre");
    String nomPreleveur = (String) request.getParameter("nomPreleveur");
    String datePrelev = (String) request.getParameter("datePrelev");
    String numFinFiche = (String) request.getParameter("numFinFiche");
         String nEtude = datePrelev + "." + idCentre + "." + numFinFiche;
    //      qu'on m�morise dans la session
    HttpSession session = request.getSession(true);
    session.setAttribute("nomCentre", nomCentre);
    session.setAttribute("idCentre", idCentre);
    session.setAttribute("nomPreleveur", nomPreleveur);
    session.setAttribute("datePrelev", datePrelev);
    session.setAttribute("numFinFiche", numFinFiche);
         Connexion com = new Connexion();
              try{     
                   //serveur,login,pwd,database
                   com.loadDriverAndConnect("127.0.0.1","3306","root","root","");
                   com.execute("USE BIOTECH");
                   com.execute("INSERT INTO RECAP (NEtude,NomCentre,idCentre,nomPreleveur,datePrelev) " +
                             "values ('"+nEtude+"','"+nomCentre+"','"+idCentre+"','"+nomPreleveur+"','"+ datePrelev + "')") ;
                   com.close();                              
              catch(Exception ex) {
                   System.err.println("\n*** SQLException caught in main()");     
              request.setAttribute("urlAction", (String) params.get("urlControleur"));
              getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(request,
    response);
              return;      
    // affichage formulaire pr�-rempli
    void doRetourFormulaire(HttpServletRequest request, HttpServletResponse response) throws
    ServletException, IOException {
    // on r�cup�re la session de l'utilisateur
    HttpSession session = request.getSession(true);
    // on pr�pare le mod�le du formulaire
    // nom pr�sent dans la session ?
    String nomCentre = (String) session.getAttribute("nomCentre");
    if (nomCentre == null) {
    session.setAttribute("nomCentre", "");
    String idCentre = (String) session.getAttribute("idCentre");
    if (idCentre == null) {
    session.setAttribute("idCentre", "");
    String nomPreleveur = (String) session.getAttribute("nomPreleveur");
    if (nomPreleveur == null) {
    session.setAttribute("nomPreleveur", "");
    String datePrelev = (String) session.getAttribute("datePrelev");
    if (datePrelev == null) {
    session.setAttribute("datePrelev", "");
    String numFinFiche = (String) session.getAttribute("numFinFiche");
    if (numFinFiche == null) {
    session.setAttribute("numFinFiche", "");
    // urlAction
    request.setAttribute("urlAction", (String) params.get("urlControleur"));
    // on affiche le formulaire
    getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
    request, response);
    return;
    // post
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    // on passe la main au GET
    doGet(request, response);
    my initial form:%
    // on r�cup�re les param�tres dans la session
         String nomCentre=(String)session.getAttribute("nomCentre");
         String idCentre= (String)session.getAttribute("idCentre");                    
         String nomPreleveur = (String)session.getAttribute("nomPreleveur");     
         String datePrelev=(String)session.getAttribute("datePrelev");          
         String numFinFiche=(String)session.getAttribute("numFinFiche");          
         String urlAction=(String)request.getAttribute("urlAction");
    %>
    <html>
    <head>
    <title>Fiche r&eacute;pitulative - formulaire</title>
    </head>
    <body>
    <center>
         <img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande" width="5%"></img>
    <h2>Fiche r&eacute;pitulative - formulaire</h2>
         <br>
    <hr>
    <form action="<%= urlAction %>" method="post">
    [... page setting: made by html language ...]
    <td><input type="submit" name="action" value="validationFormulaire"></td>
    <td><input type="reset" value="R&eacute;tablir"></td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>
    my response page:<%
    // on r�cup�re les donn�es
         String nomCentre=(String)session.getAttribute("nomCentre");
         String idCentre= (String)session.getAttribute("idCentre");                    
         String nomPreleveur = (String)session.getAttribute("nomPreleveur");     
         String datePrelev=(String)session.getAttribute("datePrelev");          
         String numFinFiche=(String)session.getAttribute("numFinFiche");     
         String urlAction=(String)request.getAttribute("urlAction");
    %>
    <html>
    <head>
    <title>Fiche r&eacute;pitulative - formulaire</title>
    </head>
    <body>
    <form action="<%= urlAction %>" method="post">
    [... page setting: made by html language ...]
    <br><br>
                   <td><input type="submit" name="action" value="enregistrementFormulaire"></td>
                   <td><input type="submit" name="action" value="retourFormulaire"></td>
    </body>
    </html>
    my web.xml:<!-- Servlets -->
    <!--Servlet Fiche Recapitulative-->
    <servlet>
    <servlet-name>FicheRecap</servlet-name>
    <servlet-class>germande.ServletRecap</servlet-class>
    <init-param>
    <param-name>urlReponse</param-name>
    <param-value>/WEB-INF/JSP/Recap/reponseRecap.biotech.jsp</param-value>
    </init-param>
    <init-param>
    <param-name>urlErreurs</param-name>
    <param-value>/erreursRecap.biotech.jsp</param-value>
    </init-param>
    <init-param>
    <param-name>urlFormulaire</param-name>
    <param-value>/WEB-INF/JSP/Recap/formulaireRecap.biotech.jsp</param-value>
    </init-param>
    <init-param>
    <param-name>urlControleur</param-name>
    <param-value>ServletRecap</param-value>
    </init-param>
    <init-param>
    <param-name>lienRetourFormulaire</param-name>
    <param-value>Retour au formulaire</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>FicheRecap</servlet-name>
    <url-pattern>/ServletRecap</url-pattern>
    </servlet-mapping>
    </web-apps>
    Thanks in advance for your idea.
    I resume : how can I call a method in my servlet into my response page (in jsp).
    the servlet generate this response page and i just want to update the choice of my user.
    Thanks !!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I resume : how can I call a method in my servlet into my response page (in jsp).Don't do that. Put the message into a plain old Java class which can be called from both the servlet and the JSP.

  • Does Weblogic 5.1 support the STANDARD javax.servlet.request.X509Certificate attribute?

    Hello!
    My strong suspicion from looking at the Weblogic SSL documentation on
    http://e-docs.bea.com is that WebLogic SSL does not put any client-side
    certificates into the 'javax.servlet.request.X509Certificate' attribute
    of a servlet's HttpServletRequest (as an array of
    java.security.cert.X509Certificate instances).
    Currently, it appears that Weblogic uses a proprietary attribute name
    ('weblogic.security.somethingOrOther') and returns instances of the
    deprecated Java 1.1 java.security.Certificate class.
    When will Weblogic support this aspect of the Servlet 2.2 specification,
    if it doesn't already?
    Regards,
    James W.

    I just verified this with the Java doc. Either the Java documentation is
    incorrect or we are still using the older version of the certificate
    encoding class. I will check on this, we may have fixed it in a subsequent
    service pack.
    Thanks,
    Michael
    Michael Girdley
    Product Manager, WebLogic Server & Express
    BEA Systems Inc
    "James Webster" <[email protected]> wrote in message
    news:[email protected]..
    Hello!
    My strong suspicion from looking at the Weblogic SSL documentation on
    http://e-docs.bea.com is that WebLogic SSL does not put any client-side
    certificates into the 'javax.servlet.request.X509Certificate' attribute
    of a servlet's HttpServletRequest (as an array of
    java.security.cert.X509Certificate instances).
    Currently, it appears that Weblogic uses a proprietary attribute name
    ('weblogic.security.somethingOrOther') and returns instances of the
    deprecated Java 1.1 java.security.Certificate class.
    When will Weblogic support this aspect of the Servlet 2.2 specification,
    if it doesn't already?
    Regards,
    James W.

  • Xhtml call to servlet not returning response, not calling servlet

    I have xhtml in a web app making a call to a servlet but the response from the servlet is not displaying. The original xhtml displays after the submit button is pressed. I tried different alternatives for the servlet response, but I get the same result each time. I added logging to the servlet, but it looks like the servlet is not being called at all.
    xhtml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:ejstreegrid="https://unfccc.int/nais/ejstreegrid"
    xmlns:grid="http://java.sun.com/jsf/composite/gridcomp"
    xmlns:nais="http://java.sun.com/jsf/composite/naiscomp">
    <body>
    <ui:composition template="/templateForm.xhtml">
    <ui:define name="title">Some title</ui:define>
    <ui:param name="currentPage" value="somepage.xhtml" />
    <ui:define name="body">
    name to be added<br/><br/>
    <form action="someServlet" method="post">
    <input type="text" name="someName" />
    <input type="submit" />
    </form>
    </ui:define>
    </ui:composition>
    </body>
    </html>servlet in web app being called:
    package netgui.servlet;
    import java.io.IOException;
    import java.util.Enumeration;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class someServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public someServlet() {
    super();
    protected void doGet(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException   {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException {
    processRequest(request, response);
    private void processRequest(HttpServletRequest request,
    HttpServletResponse response) throws IOException {
    try {
    response.getWriter().write("some response");
    } catch (Exception e) {
    logger.error(e.getMessage());
    e.printStackTrace();
    response.getWriter().println("Error: " + e.getMessage());
    I also have a menu.xhtml that is calling the xhtml file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <body>
    <script type="text/javascript">
    $(document).ready(function() {
    $("#btn").click(function() {
    $("#upload").click();
    return false;
    </script>  
    <ui:composition>
    <div id="navigation_bar">
    <ul id="topbarleft">
    <c:choose>                 
    <c:when test="${currentPage=='somepage.xhtml'}">
    <li><b>Some Page display</b></li>
    </c:when>
    <c:otherwise>
    <li><h:outputLink value="somepage.jsf">
    <h:outputText value="some page" />
    </h:outputLink></li>
    </c:otherwise>
    </c:choose>
    </ul>
    </div>
    </ui:composition>
    </body>
    </html>Is there some special format for submitting a form to a servlet from xhtml? Any ideas what could be wrong?
    Edited by: Atlas77 on Apr 16, 2012 6:53 AM
    Edited by: Atlas77 on Apr 16, 2012 6:54 AM
    Edited by: Atlas77 on Apr 16, 2012 6:56 AM
    Edited by: Atlas77 on Apr 16, 2012 7:27 AM

    You have a template. That template doesn't have for example a h:form of its own in which the body content is placed right? Nested forms don't work.
    Also for the next time, use \ tags to post code; that makes it actually readable. As you can see, the forum is now trying to interpret some special characters for formatting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Sending emails+attachment from a servlet

    Hi all,
    I'd like to send emails from within my servlet. There must be a possibility to attach a file that has been uploaded to the server in a previous request.
    Currently I'm using sun.net.smtp.SmtpClient to send simple emails.
    Does the sun-smtp-package provide a way to attach a file to an email?
    regards
    Steffen

    I'm not sure but I think the sun.net.smtp package is part of J2EE. I didn't need to download it. You will need a Base64-Encoding algorithm for transforming the file-data (the attachment) into the email message. OReillys servlet package provides a class for this (www.servlets.com).
    Below is an example how to send an email with a file attached to it. You will have to specify the name of an SMTP-Server. If you do not have one you can (for testing purposes) direct the email into a text file.
    try{
         String host = /** @todo place your smtp-server name or IP here */
         SmtpClient smtp = new SmtpClient(host);
         smtp.from(from);
         smtp.to(toList);
         PrintStream out = smtp.startMessage();
         Base64Encoder b64e = new Base64Encoder(out); // Base64Encoder is also a Stream which we will only use for the attachment-data
         /* uncomment this if there is no smtp-server. The email will be stored in a file
         File fEml = new File(/** @todo add your filePath here */+File.separatorChar+"out.eml");
         PrintStream out = new PrintStream(new FileOutputStream(fEml));*/
         out.println("From: "+from);
         out.println("To: "+toList);
         out.println("Subject: "+subject);
         out.println("Date: "+date.toString());
         out.println("MIME-Version: 1.0");
         // we have to declare the email multipart/mixed to notify the email client that this mail contains sub parts of different content-types
         out.println("Content-Type: multipart/mixed;");
         // the boundary-string separates the sub parts (just like in HTTP-Multipart-Requests)
         out.println("\tboundary=\"----=_next_part\"");
         out.println("\r");
         out.println("This is a multipart message in MIME format.");
         out.println("\r");
         // first sub part starts here - its the text message
         out.println("------=_next_part");
         // this sub part contains only plain text
         out.println("Content-Type: text/plain;");
         out.println("\tcharset=\"iso-8859-1\"");
         out.println("Content-Transfer-Encoding: 7bit");
         out.println("\r");
         // Message text goes here
         out.println(/** @todo place your message here */);
         out.println("\r");
         // now the attachment
    out.println("------=_next_part");
    out.println("Content-Type: application/octet-stream;");
    out.println("\tname=\""+fileName+"\"");
    out.println("Content-Transfer-Encoding: base64");
    out.println("Content-Disposition: attachment;");
    out.println("\tfilename=\""+fileName+"\"");
    out.println("\n");
    // encode file piece by piece
    File f = new File(/** @todo place your filepath here */+File.separatorChar+fileName);
    FileInputStream fis = new FileInputStream(f);
    int i = 0;
    do{
    byte[] content = {0, 0, 0};
    i = fis.read(content, 0, 3);
    if (i != -1){
                   b64e.write(content);
         }//if
    }while(i != -1);
    fis.close();
    fis = null;
    f = null;
         // this is it, all there's left to do is to flush our output-stream and clean up
         out.flush();
         b64e.close();
         out.close();
         b64e = null;
         smtp.closeServer();
         out = null;
         smtp = null;
    }catch(IOException ioe){
         ioe.printStackTrace();
    }//catch
    HTH
    Steffen

  • How can i send xml file with a http servlet request

    Hi
    Please tell me how can I send a xml file into http servlet request.
    I have a servlet(action) java file.From this servlet I have generate a xml file. Now I need to send that xml file to another servlet with http servlet request object.
    Dave.

    When you say you have generated an XML file what do you mean?
    Is it a file stored on disk? Then pass the file path as a string to the servlet.
    Is it stored in memory as an object? The pass a reference to the object to the servlet.
    Or are you asking how to communicate between servlets?
    Look in the JavaDocs for the RequestDispatcher class. You can use this class to forward the request to another servlet. Data can be passes using the RequestDispatcher by storing it as attributes using the request getAttribute and setAttribute methods. Also described in the JavaDOcs.
    http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html

  • Servlet with 2 Response Streams

    I want to create a Servlet with 2 response streams. I need to use 1 response Stream to send Continuous Updates received on the server
    and the other response Stream would be used to send Heartbeats to the Client. I tried to create the Servlet but the response I create to send the continuous data just stops sending data to the Client after many attempts. In this attached Servlet, The response for continuous data stopped after 150 refreshes.
    Please let me know how to fix the issue. I tried reset() too but does not seem to work. Will very much appreciate any help.
    package com.XX;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class TestServlet extends HttpServlet{
         private static final long serialVersionUID = 1L;
         public static int count = 0;
         private TestSave testSave = null;
         private HttpServletResponse resp = null;
         public void init(){
              testSave = new TestSave();
         protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
              count ++;
              if(testSave == null){
                   System.out.println(" test save = null");
                   return;
              if(testSave.getRes()==null){
              System.out.println(" test save resp is null");          
              testSave.setRes(res);
              res.getWriter().println(" Initial Daily count Response ");
              }else{
              res.getWriter().println(" Daily response " + count);
              //res.getWriter().close();
         System.out.println(" test save resp is not null");
              resp = testSave.getRes();
              String data = "Count is "+count;
              System.out.println(" Writing response " + resp);
              System.out.println(" Writing Data " + data);
              System.out.println(" Response committed 1 - " + count + " : " + resp.isCommitted());
              resp.getWriter().println(data);
              System.out.println(" Response committed 2 - " + count + " : " + resp.isCommitted());
              System.out.println(" Daily Response committed ??? " + res.isCommitted());
         protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
              doGet(req,res);          
    }

    The TestSave code.
    import javax.servlet.http.HttpServletResponse;
    public class TestSave {
         HttpServletResponse res;
         public HttpServletResponse getRes() {
              return res;
         public void setRes(HttpServletResponse res) {
              this.res = res;
    }

  • HTTPS Servlet requests

              After installing service pack 9 from WL5.1, HTTPS servlet requests result in the
              browser returning a server error. Issue 41888 of sp9 seems to address this. We
              were previously running service pack 6 and didn't experience this problem. Any
              ideas?
              

    Have you installed SP9 properly?
              I just tried accessing example servlets on Https protocol and i don't see any
              errors.
              Could you tell us what problems you are facing? Any test case?
              Kumar
              Darren Collins wrote:
              > After installing service pack 9 from WL5.1, HTTPS servlet requests result in the
              > browser returning a server error. Issue 41888 of sp9 seems to address this. We
              > were previously running service pack 6 and didn't experience this problem. Any
              > ideas?
              

  • Servlet to servlet communication in the same server

    Hi everybody!
    I have two .wars in the same JBoss + Tomcat web server. Both .war have their own login system throught j_security_check. I'm using Struts for development and Win 2003 for OS.
    I want to login into .war 1 and "use" Action class of .war 2. Is there any way I can do this? I found piece of code to put response and request to other servlet (from servlet 1) with RequestDispatcher, but how can i catch this new response and request in .war 2 (servlet 2)? And how to fix login in servlet 2?
    Piece of code that i found:
    ServletContext context = session.getServletContext();
    RequestDispatcher rd = context.getRequestDispatcher("/ServletName/Action.do");
    rd.include(request, response);          Tnx,
    Stanislav

    Not realy...
    The way I do it is that I put the data I need in webapp2/Servlet2 in the session >in the webapp1/Servlet1 and then redirects. The session should be managed >over the different web-applications.
    Have to check the documentation if you need to set something to have >cross-application session...How can you share session between two different .war files (i presume different context and diferent session)? In mine situation i have two different realm, also...

  • How can i do the servlet to servlet communicaion usingservlet context

    public void doGet(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              response.setContentType("text/html");
              //ServletContext context = null;
              PrintWriter out = response.getWriter();
              RequestDispatcher rd=request.getRequestDispatcher("/second");
              rd.forward(request,response);
              out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
              out.println("<HTML>");
              out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
              out.println(" <BODY>");
              /*out.print(" This is ");
              out.print(this.getClass());
              out.println(", using the GET method");*/
              out.println(" </BODY>");
              out.println("</HTML>");
              out.flush();
              out.close();
    Here I have used request.getRequestDispatcher("/second ").. it wil cal the second servlet...
    But how can i cal the second servlet using context.requestDispatcher(" ") inside the paranthesis what i wil give?
    plz some one help me..

    request.getRequestDispatcher("/second ") is the same as context.requestDispatcher("/second ") .
    The requestDispatcher from the request object can take a relative path but if the path starts with a '/' it is interpreted as relative to the context root. The RequestDispatcher from the context can only take paths that start with '/' and are relative to the context root.
    http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang.String)

Maybe you are looking for

  • How to submit InfoPath form data to multiple SharePoint lists at one time?

    Hi, I'm looking for a way to submit certain data in InfoPath form to separate SharePoint lists at the same time. I have a form that has two views with many data in them. I want to keep these data in separate SharePoint list besides keeping them in th

  • In search of Unity 5 ES89

    Does anyone know if ES89 is available, just not public? Trying to setup Digital Networking or Unity to Unity Connection Interchange and understand that for Unity 5 you need ES89. http://www.cisco.com/en/US/partner/docs/voice_ip_comm/unity/compatibili

  • Bapi in ECC 6.0

    Hi, Can anybody tell me if Table parameter is obsolete for Bapi in ECC 6.0? if yes, wts the alternative? reward points guaranteed. Message was edited by:         Anid

  • Aperture 3.5 "Not Responding" but using CPU ...

    I'm on a 2012 Macbook Pro 15" with Retina. 2.7 i7 CPU, 16BG of RAM, a nice fat SSD with 40 GB of free space. Updated on Mavericks as of this date... Just installed Aperture 3.5 Importing old iPhone Library to NEW Aperture Library because I was experi

  • Converting files to PDF, failed print jobs

    Hi, Every time I convert a file to PDF I then receive a failed print job in my print queue. Has anyone seen this before? Adobe prints to LPT1. Thanks.