Skip to content
This repository was archived by the owner on Aug 16, 2025. It is now read-only.

Handling post requests

laxika edited this page Sep 9, 2013 · 1 revision

Handling POST request is easy in Torch. You can get POST variables by calling request.getPostData().getVariable("postvarname"). This will return you a PostVariable object. You can call getName() and getValue() on it to get it's name/value.

You can also iterate over the post variables just like you did with the route variables:

for (PostVariable postVar : request.getPostData()) {
    response.appendContent("Post var: <b>" + postVar.getName() + "</b> = '" + postVar.getValue()+"'<br>");
}

Clone this wiki locally