🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
4 messages
4 total messages Started by Jonathan Estabillo Thu, 02 Dec 2004 02:59
Cannot pass parameters using GET method when using URLConnection in java.net
#14
Author: Jonathan Estabillo
Date: Thu, 02 Dec 2004 02:59
49 lines
2590 bytes
Hi there everyone. I am finding a hard time sending URL parameters using 
the java.net package. I can connect to the specific URL but it seems 
that the parameters are not being passed. How do I go about it? By the 
way here is the code for a simple application to pass URL parameters 
using the GET method but in reality it does not pass the parameters:

	
		HERE IS THE CODE THAT I'M TRYING TO WORK ON
***************************************************************************
package testing;

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

public class Servlet1 extends HttpServlet {

     //Initialize global variables
     public void init() throws ServletException {
     }

     public void doGet(HttpServletRequest request, HttpServletResponse 
response) throws
             ServletException, IOException {
         try {
             URL url = new URL(
                     "http://confserver:8500/index.cfm?");
             URLConnection conn = url.openConnection();
             conn.setDoOutput(true);
             OutputStreamWriter wr = new 
OutputStreamWriter(conn.getOutputStream());
             wr.write("SMS_MsgTxt=Jonathan");
             wr.close();
         } catch (Exception ex) {
             ex.printStackTrace();
         }
     }

     public void doPost(HttpServletRequest request, HttpServletResponse 
response) throws
             ServletException, IOException {
         doGet(request, response);
     }

     //Clean up resources
     public void destroy() {
     }
}
Re: Cannot pass parameters using GET method when using URLConnectionin java.net
#15
Author: Paul Furbacher [TeamB]
Date: Thu, 02 Dec 2004 13:57
29 lines
1902 bytes
Jonathan Estabillo wrote:

> [...] I am finding a hard time sending URL parameters using 
> the java.net package. [...]

Don't have time to parse your code.
The most efficient thing you could do is to
get the com.oreilly.servlets package from

   http://www.servlets.com

and use the HttpMessage class and others
to do this.


-- 


Paul Furbacher (TeamB)

   Save time, search the archives:
        http://www.borland.com/newsgroups/ngsearch.html

   Is it in Joi Ellis's Faq-O-Matic?
        http://www.visi.com/~gyles19/fom-serve/cache/1.html

   Finally, please send responses to the newsgroup only.
   That means, do not send email directly to me.
   Thank you.
Re: Cannot pass parameters using GET method when using URLConnection in java.net
#16
Author: Lars Henriksen
Date: Mon, 06 Dec 2004 16:19
63 lines
2959 bytes
Hi....

    Why not just do it directly? As in

    URL url = new 
URL("http://confserver:8500/index.cfm?SMS_MsgTxt=Jonathan");


    Or..?

        Regards, Lars Henriksen

"Jonathan Estabillo" <nathanestabillo@netscape.net> skrev i en meddelelse 
news:41ae84eb$1@newsgroups.borland.com...
> Hi there everyone. I am finding a hard time sending URL parameters using 
> the java.net package. I can connect to the specific URL but it seems that 
> the parameters are not being passed. How do I go about it? By the way here 
> is the code for a simple application to pass URL parameters using the GET 
> method but in reality it does not pass the parameters:
>
>
> HERE IS THE CODE THAT I'M TRYING TO WORK ON
> ***************************************************************************
> package testing;
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.net.*;
>
> public class Servlet1 extends HttpServlet {
>
>     //Initialize global variables
>     public void init() throws ServletException {
>     }
>
>     public void doGet(HttpServletRequest request, HttpServletResponse 
> response) throws
>             ServletException, IOException {
>         try {
>             URL url = new URL(
>                     "http://confserver:8500/index.cfm?");
>             URLConnection conn = url.openConnection();
>             conn.setDoOutput(true);
>             OutputStreamWriter wr = new 
> OutputStreamWriter(conn.getOutputStream());
>             wr.write("SMS_MsgTxt=Jonathan");
>             wr.close();
>         } catch (Exception ex) {
>             ex.printStackTrace();
>         }
>     }
>
>     public void doPost(HttpServletRequest request, HttpServletResponse 
> response) throws
>             ServletException, IOException {
>         doGet(request, response);
>     }
>
>     //Clean up resources
>     public void destroy() {
>     }
> } 
Re: Cannot pass parameters using GET method when using URLConnection in java.net
#47
Author: Michael Clark
Date: Thu, 17 Feb 2005 06:22
58 lines
2877 bytes
Try this:

URL url = new URL("http://confserver:8500/index.cfm?SMS_MsgTxt=Jonathan");
URLConnection conn = url.connect();
conn.getInputStream().close();


"Jonathan Estabillo" <nathanestabillo@netscape.net> wrote in message 
news:41ae84eb$1@newsgroups.borland.com...
> Hi there everyone. I am finding a hard time sending URL parameters using 
> the java.net package. I can connect to the specific URL but it seems that 
> the parameters are not being passed. How do I go about it? By the way here 
> is the code for a simple application to pass URL parameters using the GET 
> method but in reality it does not pass the parameters:
>
>
> HERE IS THE CODE THAT I'M TRYING TO WORK ON
> ***************************************************************************
> package testing;
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
> import java.net.*;
>
> public class Servlet1 extends HttpServlet {
>
>     //Initialize global variables
>     public void init() throws ServletException {
>     }
>
>     public void doGet(HttpServletRequest request, HttpServletResponse 
> response) throws
>             ServletException, IOException {
>         try {
>             URL url = new URL(
>                     "http://confserver:8500/index.cfm?");
>             URLConnection conn = url.openConnection();
>             conn.setDoOutput(true);
>             OutputStreamWriter wr = new 
> OutputStreamWriter(conn.getOutputStream());
>             wr.write("SMS_MsgTxt=Jonathan");
>             wr.close();
>         } catch (Exception ex) {
>             ex.printStackTrace();
>         }
>     }
>
>     public void doPost(HttpServletRequest request, HttpServletResponse 
> response) throws
>             ServletException, IOException {
>         doGet(request, response);
>     }
>
>     //Clean up resources
>     public void destroy() {
>     }
> } 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads