ALEX L schrieb:

> Dear All,
> Is it possible to have a servlet to call a server application. If it
> can be done, how can the servlet call the server application. In DOS
> we can run the server application by using "java server" but how can a
> servlet run a server application. My server application  will be
> waiting for a client connection, and is a thread to do some
> calcualtion and also waiting for a client input. That's what my server
> do.
> Please help.
> Thanks a lot for your time.
>
> Regards,
> Alex

Hello Alex!

I use the following Servlet to call a server application. In the code I call
the directory application on an Unix computer.


-------------------------------------------------------
Dipl.-Wirt.Inform.
Wolfgang B�ning
Am Gro�en Kamp 8
46342 Velen
Tel.: 02863/1800
Fax: 089/6661715486
Email: [EMAIL PROTECTED]
WWW: http://www.wi-inf.uni-essen.de/~buening
-------------------------------------------------------

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class texec extends HttpServlet
{
    public void doGet (HttpServletRequest request,
                       HttpServletResponse response)
        throws ServletException, IOException
        {
            PrintWriter out;
            String title = "Execution test";
            response.setContentType("text/html");
            out = response.getWriter();
            out.println("<HTML><HEAD><TITLE>");
            out.println(title);
            out.println("</TITLE></HEAD><BODY bgcolor=\"#FFFFFF\">");

      Runtime RT=Runtime.getRuntime();
      Process PR;
      try{
        PR=RT.exec("/bin/ls -l");
        String s=new String();
        if (PR!=null){
         DataInputStream dis=new DataInputStream(PR.getInputStream());
         while((s=dis.readLine())!=null){
          out.println(s+"<BR>");
         }
        }
      }
      catch(IOException e){
       System.err.println("Fehler: " +e);
      }
      out.println("</BODY></HTML>");
      System.out.println("TEST");
            out.close();
        }
}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to