Segue into URL binding

Whilst this should be relatively known to people with any web application development experience, this brief segue lays the foundations for SEO friendliness and will be used for all subsequent encoding types. The (correct) use of URL binding will increase SEO and readability of URLs which should increase SEO rankings.

What is URL binding

Rather than creating some sort of hierarchy of folders and documents, it is possible to bind a specific regular expression pattern to a URL which then invokes a servlet1. This servlet then has access not only to the invoking path, but also to any query parameters that are passed through.

Example

Let us start with an example of URL binding. We will ‘bind’ the SSA to a specific URL, rather than a specific page with search parameters.

In our original Type 0 encoding example the page that is hit is:

http://example.com/search.jsp

In fact this already has a binding placed on it – just not the binding we are interested in. In your favourite web application container (in this example Tomcat) you will see something along the lines of:


<servlet-mapping>
  <servlet-name>jsp</servlet-name>
  <url-pattern>*.jsp</url-pattern>
</servlet-mapping>

Which maps all URLs with a *.jsp to the JSP compiling and execution servlet thusly:


<servlet>
  <servlet-name>jsp</servlet-name>
  <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
  <init-param>
    <param-name>fork</param-name>
    <param-value>false</param-value>
  </init-param>
  <init-param>
    <param-name>xpoweredBy</param-name>
    <param-value>false</param-value>
  </init-param>
  <load-on-startup>3</load-on-startup>
</servlet>

I have highlighted the lines of interest. Here it says to create a servlet named jsp which will invoke the servlet class rg.apache.jasper.servlet.JspServlet. The named servlet (jsp) is then mapped to be invoked by any URL which matches the pattern *.jsp.

So, to increase SEO, we can bind the SSA to any URL that starts with /search/*. If we were to write this for tomcat:


<servlet>
  <servlet-name>search</servlet-name>
  <servlet-class>some.classpath.SearchServlet</servlet-class>
  <init-param>
    <param-name>fork</param-name>
    <param-value>false</param-value>
  </init-param>
  <init-param>
    <param-name>xpoweredBy</param-name>
    <param-value>false</param-value>
  </init-param>
  <load-on-startup>3</load-on-startup>
</servlet>

<servlet-mapping>
  <servlet-name>search</servlet-name>
  <url-pattern>/search/*</url-pattern>
</servlet-mapping>

Any URL that starts with http://example.com/search/ would invoke the search servlet and pass all of the path and query details though.

So for our first example URL, with the URL binding above, this would turn into


http://example.com/search/?
  q=super&
  cat=action&
  cat=drama&
  sort=price&
  edition=special&
  num=25

Note that the query parameters are still passed through, we have just removed the ‘.jsp’ part and replaced it with a forward slash ‘/’. Furthermore, the URL of

http://example.com/search/any/other/text/here/?key1=value1&key2=value2

would still go through the search servlet, however the search servlet now has access to both the request parameters of key1 and key2 and request URL of /any/other/text/here/.

Up next

For all of the following encoding types we will assume that the SOLR SSA will be bound to the URL /search/*.

The next encoding type uses some of the points touched on in the last paragraph… Now that we have this sorted, on with the next encoding type. »

Navigation:

Use the following links to skip straight to a page, or browse through the pages one by one.

  1. The Site Search Appliance
  2. Type 0 – Request Parameters
  3. Segue into URL binding
  4. Type 1 – Throwaway URLs with Request Parameters
  5. Type 2 – Parsing Hint Positional URLs
  6. Type 3 – Hard-coded Positional Parameters
  7. Type 4 – Positional Parameters with Encoded Parsing Hints
  8. Type 5 – Extra Information Positional Parameters with Encoded Parsing Hints
  9. Encoding Type Showdown
  10. Final Note

Footnotes:

  1. Yes, this is a Java based term, whilst the nomenclature may be different for other languages, the theory remains the same

Like my footnotes?
Want to add footnotes to your blog?
They can be added easily to your WordPress installation