BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cannot pass parameters using GET method when using URLConnec

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI
View previous topic :: View next topic  
Author Message
Jonathan Estabillo
Guest





PostPosted: Thu Dec 02, 2004 2:59 am    Post subject: Cannot pass parameters using GET method when using URLConnec Reply with quote



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() {
}
}
Back to top
Paul Furbacher [TeamB]
Guest





PostPosted: Thu Dec 02, 2004 1:57 pm    Post subject: Re: Cannot pass parameters using GET method when using URLCo Reply with quote



Jonathan Estabillo wrote:

Quote:
[...] 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.

Back to top
Lars Henriksen
Guest





PostPosted: Mon Dec 06, 2004 4:19 pm    Post subject: Re: Cannot pass parameters using GET method when using URLCo Reply with quote



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 (AT) netscape (DOT) net> skrev i en meddelelse
news:41ae84eb$1 (AT) newsgroups (DOT) borland.com...
Quote:
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() {
}
}



Back to top
Michael Clark
Guest





PostPosted: Thu Feb 17, 2005 6:22 am    Post subject: Re: Cannot pass parameters using GET method when using URLCo Reply with quote

Try this:

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


"Jonathan Estabillo" <nathanestabillo (AT) netscape (DOT) net> wrote

Quote:
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() {
}
}



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder JavaAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.