0

A rookie question:

I have a simple submission form, the problem is if there is any space given for the inputs the value gets changed to a plus(+).

This is my form:

<form name="input" action="search" method="get">
Web Address: <input type="text" name="address"><br>
Search Query: <input type="text" name="query"><br>
<input type="submit" value="Search">
</form>

I'd like to give an example:

if user fills "address here" to the first box and "query here" to the second box. The address that I get after the click is "search?address=address+here&query=query+here" instead of "search?address=address%20here&query=query%20here". How can I change these "namespaces" with %20 instead of + signs?

The reason why I don't want plus sign instead of %20 is because I am writing a search engine in Java language and using sun's httpserver library for the web server. This library handles the "query" part of the result(which is after? sign) by using .getRequestURI().getQuery() method, however this method handles %20 as space and sees plus sign as plus. If this is not "fixable" then I can also accept a solution that involves javascript.

Sarp Kaya
  • 3,686
  • 21
  • 64
  • 103
  • 4
    It's urlencoded and shouldn't matter … browsers will decode the value again. – knittl Sep 22 '13 at 09:42
  • 1
    It isn't urlencoded, it is form-urlencoded, which is subtly different (the `+` instead of `%20` is the only difference I'm aware of though). **Browsers** will not decode the value. Any form processing library should though. – Quentin Sep 22 '13 at 09:43
  • I am using this information in Java, unfortunately it does matter in my case as this is not a browser question. – Sarp Kaya Sep 22 '13 at 09:45
  • @SarpKaya — How are you using it in Java? What functions are you using to read the query string? – Quentin Sep 22 '13 at 09:46
  • @Quentin I wrote the detailed reason now – Sarp Kaya Sep 22 '13 at 09:50
  • @SarpKaya — Please provide more code. How are you reading the query string? – Quentin Sep 22 '13 at 09:55
  • @Quentin with .getRequestURI().getQuery() method – Sarp Kaya Sep 22 '13 at 09:56
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/37814/discussion-between-sarp-kaya-and-quentin) – Sarp Kaya Sep 22 '13 at 09:59
  • related: https://stackoverflow.com/q/1634271, https://stackoverflow.com/q/2678551 – djvg Nov 03 '22 at 20:20

1 Answers1

-1

The encoding of the space symbol into a plus is due to the standard application/x-www-form-urlencoded encoding which your form is using, so I don't think this is possible.

Efran Cobisi
  • 6,138
  • 22
  • 22