Wt Web Toolkit: Get URL parameter string values

If you want to access an url parameter string in Witty C++ HTML Web Toolkit there is an easy way to do so. Imagine you want to get the content of the parameter “param” in a URL like http://www.myurl.com/?param=test. To do so you can use the following code in your Wt Application class:
[sourcecode language=”cpp”]

#include <Wt/WApplication>
#include <Wt/WEnvironment>
#include <string>
#include <iostream>

using namespace Wt;

class myApplication: public WApplication
myApplication(const WEnvironment& env)
: WApplication(env)
setTitle("This is an application");

addMetaHeader ("description","a description");

const std::string* param = this->environment().getParameter("param");

if (param!=0)
std::cout << (*param) << std::endl;




Also have a look of the handling of internal paths in Wt Web Toolkit:


Leave a Reply

Your email address will not be published. Required fields are marked *