Entering Post info in Java

So I usually enter 2 strings, the name and value.

But this one....

<input type='text' name='fill' format='N' value='0' />

It says "Only numeric characters", but i'm only entering numeric characters. I thought you always submitted it with 2 strings, the name and the value.

Do I need to enter it as an Integer? Or what? I'm asking here rather than doing it first because it would require lots of rewriting throughout the program.

[475 byte] By [Bogada] at [2007-11-27 7:44:48]
# 1
Huh?You are aware of the fact that this is a Java forum, right?
prometheuzza at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 2

This is Java!

URL urll = new URL("http://www.whitehouse.com/game/gasstation.php?action=fill");

URLConnection connection2 = urll.openConnection();

connection2.setDoOutput(true);

PrintWriter outt = new PrintWriter(connection2.getOutputStream());

Map<String, String> postt = new HashMap<String, String>();

postt.put("fill","96");

boolean firstt = true;

for (Map.Entry<String, String> pair : postt.entrySet())

{

if (firstt) firstt = false;

else outt.print('&');

String name = pair.getKey();

String value = pair.getValue();

outt.print(name);

outt.print('=');

outt.print(URLEncoder.encode(value, "UTF-8"));

}

out.close();

Bogada at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 3
> This is Java!> > ...Yes, that is Java.What's your question about that code?
prometheuzza at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 4

So I usually enter 2 strings, the name and value.

But this one....

<input type='text' name='fill' format='N' value='0' />

It says "Only numeric characters", but i'm only entering numeric characters. I thought you always submitted it with 2 strings, the name and the value.

Do I need to enter it as an Integer? Or what? I'm asking here rather than doing it first because it would require lots of rewriting throughout the program.

Bogada at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 5
This is where I came in!
Hippolytea at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 6
> So I usually enter 2 strings, the name and value.> ...It seems there's an echo in here.
prometheuzza at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 7
I thought it was pretty clear.... what part of the question do you not get?
Bogada at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 8

> I thought it was pretty clear.... what part of the

> question do you not get?

Every part of it. I don't see how your original post and the code you posted afterwards have anything to do with another.

But don't explain it any further to me: if you think you explained it well enough for other people to help you, then it must be me.

Good luck.

prometheuzza at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 9

Maybe this is better...

I'm sending thru a post form like this...

<input type='text' name='fill' format='N' value='0' />

And when I do that I get an error because it's expecting a number. But I sent it a number!

I thought it would only recieve the data and not the format, are you not supposed to encode numbers when you send them?

Bogada at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...
# 10

> And when I do that I get an error because it's

> expecting a number. But I sent it a number!

So you say. From that code all I can see is that you sent it a String. Getting error messages is a sign that perhaps you are making an error, so my guess is that your String doesn't contain only digits, or something. Have you considered looking at it via some kind of debugging statement? Just saying "I'm right" isn't very helpful in my experience.

> I thought it would only recieve the data and not the

> format, are you not supposed to encode numbers when

> you send them?

Sure, you're supposed to URL-encode the values of your URL parameters. And if your parameter is a string of digits that should not change it at all.

DrClapa at 2007-7-12 19:25:25 > top of Java-index,Java Essentials,Java Programming...