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:

#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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: