🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #16

Re: Cannot pass parameters using GET method when using URLConnection in java.net

#16
From: 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() {
>     }
> } 
Technical Details
Message-ID: <fE%sd.272$3j3.190@news.get2net.dk>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed1.uni2.dk!news.get2net.dk.POSTED!53ab2750!not-for-mail
References: <41ae84eb$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1089d0,a6b579cb5bacaf3b
X-Google-Attributes: gid1089d0,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed1.uni2.dk!news.get2net.dk.POSTED!53ab2750!not-for-mail
From: "Lars Henriksen" <asd@asd.asd>
Newsgroups: borland.public.jbuilder.java.api
References: <41ae84eb$1@newsgroups.borland.com>
Subject: Re: Cannot pass parameters using GET method when using URLConnection in java.net
Lines: 65
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
Message-ID: <fE%sd.272$3j3.190@news.get2net.dk>
Date: Mon, 6 Dec 2004 17:19:11 +0100
NNTP-Posting-Host: 192.38.163.100
X-Complaints-To: abuse@uni2.dk
X-Trace: news.get2net.dk 1102349963 192.38.163.100 (Mon, 06 Dec 2004 17:19:23 CET)
NNTP-Posting-Date: Mon, 06 Dec 2004 17:19:23 CET
Organization: UNI2 Internet Kunde