Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2005

Tip: Looking for answers? Try searching our database.

How to send a request to JSP from a standalone java program

Thread view: 
Venkat - 28 Feb 2005 12:46 GMT
Hi All,

I have to send a request to JSP with some key value pairs which is
executing in a Web server. Please help me in solving this problem.

I tried with the following procedure but I am not successful.

{

       URL url;
      StringBuffer buffer;
      String line;
      int responseCode;
      HttpURLConnection connection;
      InputStream input;
      BufferedReader dataInput;
     
      try
      {
     
      url = new URL("http://202.62.87.235//kidosoftware//mpayment.jsp");
        connection = (HttpURLConnection)url.openConnection();
      connection.setDoOutput(true);
      connection.connect();
        OutputStream os = connection.getOutputStream();     
      PrintWriter out = new PrintWriter(os);     
     
      out.write("key1=asdf");
      os.close();
     
      responseCode = connection.getResponseCode();
      System.out.println("response code is"+responseCode);
     
      connection.disconnect();
      .
      .
      .
       .

}

Thanks in advance
--Venkat
Darius - 28 Feb 2005 15:08 GMT
Put the "out.write("key1=asdf")" into the URL...
then use Input rather than Output to read the result.
Venkat - 01 Mar 2005 05:11 GMT
> Put the "out.write("key1=asdf")" into the URL...
> then use Input rather than Output to read the result.

If if I keep the "key1=asdf" in the URL , then data will go as "GET" method which
is not good for large amounts of data.I want to send the data as request body

Thanks
--Venkat
Raymond DeCampo - 28 Feb 2005 23:35 GMT
> Hi All,
>
> I have to send a request to JSP with some key value pairs which is
> executing in a Web server. Please help me in solving this problem.

Take a look at the free HttpClient module from Apache.

HTH,
Ray

Signature

XML is the programmer's duct tape.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.