I want to interpret legacy permalinks to my old blog in my new blog app. The old links are forwarded and turn into links like these:


http://eelcovisser.org/blog/index.php?/archives/152-Static-Consistency-Checking-of-Web-Applications-with-WebDSL.html

The page definition for blog used to be


define page blog(index: Int) { … }

but I can turn it into something like


define page blog(arg1: String, arg2: String, arg3: String) {

But unfortunately, only ‘index.php’ gets bound to ‘arg1’. How can I access the rest of the page arguments?

Submitted by Eelco Visser on 30 April 2011 at 21:46

On 30 April 2011 at 22:36 Danny Groenewegen commented:

The ? will cause the rest to become part of the query string. Either

http://eelcovisser.org/blog/index.php/archives/152-Static-Consistency-Checking-of-Web-Applications-with-WebDSL.html

or

http://eelcovisser.org/blog/index.php?arg2=/archives/152-Static-Consistency-Checking-of-Web-Applications-with-WebDSL.html

would work but require URL rewriting.

You can also gain access to the raw query string using a helper Java class (store as nativejava/helper/GetRequest.java):

package helper;
import utils.ThreadLocalServlet;

public class GetRequest {
  public static String getQueryString(){
	  return ThreadLocalServlet.get().getRequest().getQueryString();
  }
}

declaration in app:

    define page blog(s:String){	         
      output(Request.getQueryString())
    }
    
    native class helper.GetRequest as Request{
      static getQueryString():String
    }

Log in to post comments