I believe that u need the servername in ur servlet to get the current
servername so that u can connect to some other servlet in the same server..
Is that correct...

If this is true then u dont need to "try" to get a parameter in .. u can use
the servletcontext methods to achieve the same.

If not, then I believe u r missing the point here. serverName is property of
ur simple class that calls the servlet.
Now u r passing a datastream to the servlet ( some UTF data)..
If u need to access the property of a class then u need to pass the object
of the class itself to the servlet using an ObjectStream.

I hope I have been able to explain what u r missing..

Regards
Rohit Parik

----- Original Message -----
  From: Ashwini Bhat
  To: [EMAIL PROTECTED]
  Sent: Wednesday, May 23, 2001 11:51 AM
  Subject: Re: GetParameter()-IllegalArgumentException


  The appservlet code is as follows:

  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import java.net.*;
  import java.io.*;

  public class AppServlet extends HttpServlet{
          DataInputStream dis;
          DataOutputStream dos;
          URL url;
          URLConnection con;
          String s,s1;

        public void init(){
                 }

          public void service(HttpServletRequest req, HttpServletResponse
res)throws
  IOException, ServletException{


                  System.out.println("In service of AppServlet");

                  /* *****************************************************
*/
                  // TRYING TO READ THE DATA FROM THE TEST.CLASS
                  s=req.getParameter("serverName");
                  System.out.println("The server Name to be connected is
"+s);
                  System.out.println("Server name is " +s);
                  /* *****************************************************
*/


                  // CONNECTING TO SOMEOTHER SERVLET
                  url=new URL("http://"+s+":8080/servlet/AppServletAA";);
                  con=url.openConnection();
                  System.out.println("connection open");
                  con.setUseCaches(false);

con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
                  con.setDoInput(true);
                  con.setDoOutput(true);

                  dis=new DataInputStream(con.getInputStream());
                  System.out.println("input stream");
                  String s=dis.readUTF();
                  System.out.println("AppServlet "+s);

                  dos=new DataOutputStream(res.getOutputStream());
                  System.out.println("output stream in AppServ");

                  dos.writeUTF(s);

                  }catch(Exception e){
                          System.out.println("AppServlet"+e);
                  }
          }
  }


  /*

****************************************************************************
  ************* */
  The simple class is as follows
  /*

****************************************************************************
  ************* */


  import java.net.*;
  import java.util.*;
  import java.io.*;
  import java.net.*;
  import javacom.*;


  public class Test {

          URL url;
          URLConnection con;
          String ss;

          public Test(){

           }
          public String display(String tSerName){
                          try {

                                  /*
***************************************************** */
                                  // POPULATING THE VALUE OF serverName

                                  String serverName= tSerName;
                                  url=new
URL("http://"+serverName+":8080/servlet/AppServlet";);
                                  System.out.println("server name
"+serverName +" "+tSerName);
                                  /*
***************************************************** */


                                  //CONNECTING TO THE SERVLET APPSERVLET.
                                  con=url.openConnection();
                                  con.setUseCaches(false);

con.setRequestProperty("CONTENT_TYPE","application/octet-stream");
                                  con.setDoInput(true);
                                  con.setDoOutput(true);
                                  con=url.openConnection();
                                  con.setUseCaches(false);
                                  con.setDoInput(true);
                                  con.setDoOutput(true);

con.setRequestProperty("CONTENT_TYPE","application/octet-stream");

                                  System.out.println("................
xxxxx");
                                  DataOutputStream dos =new
DataOutputStream(con.getOutputStream());
                                  dos.writeUTF("LocalData");
                                  System.out.println("dummy test
connecting");

                                  dos.flush();

                                  DataInputStream dis =new
  DataInputStream(con.getInputStream());

                                  ss=dis.readUTF();
                                  System.out.println("simply reading");
                                  System.out.println(ss);

                                  //dis.close();
                                  //dos.close();
                                 }catch(Exception e){
                                          System.out.println("Client
Exception1................");
                                          e.printStackTrace();
                                  }//end of catch
                                  System.out.println("before return in
test");
                                  return (ss);

                          }// end of method

        public static void main(String s[]) throws Exception{

          /*
             THE test object is called in VB
             THE following line establishes a connection with J-Integra
          */

        com.linar.jintegra.Jvm.register("serverjvm");
        Thread.sleep(6000000);
        }

        }//end of class


___________________________________________________________________________
  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

___________________________________________________________________________
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