[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Webrick Query-String

Christian Kerth

11/29/2007 4:12:00 PM

Hey!

I have a Webrick Server set up.

When i do a GET Request i can access the query string values with:

req.query['key']

When i do a POST request (action="/myServlet?view=test") out of a form i
can acces the form fields with

req.query['field']

but i don't have access to the query string field 'view'.

The method req.query_string returns the correct string.

Is there a way to access the query string values in both request types
in a similar way? What is best practice for accessing values (query and
post data) in general?

thx
--
Posted via http://www.ruby-....

1 Answer

Peter Hickman

11/29/2007 4:27:00 PM

0

Christian Kerth wrote:
> Hey!
>
> I have a Webrick Server set up.
>
> When i do a GET Request i can access the query string values with:
>
> req.query['key']
>
> When i do a POST request (action="/myServlet?view=test") out of a form i
> can acces the form fields with
>
> req.query['field']
>
> but i don't have access to the query string field 'view'.
>
> The method req.query_string returns the correct string.
>
> Is there a way to access the query string values in both request types
> in a similar way? What is best practice for accessing values (query and
> post data) in general?
>
> thx
>

It is my understanding that post requests do not have arguments in the
url (the ?view=test part of your example), only gets.

If you are using a form you would need something like

<form action="/myServlet" method="POST">
<input type="hidden" name="view" value="test" />
...
<input type="submit"/>
</form>