The URL optimization classes provide functionality for encoding path parameters and moving path parameters from the query string into the path-params section of the URL.
In order to create directory-style URLs, you can limit the number of parameters in the query string by configuring a list of parameters to move from the query string and into the path-params section of the URL. For example, the following URL has the parameters N, Ntk, Ntt, and Ntx in the query string:
http://localhost/ContentAssemblerRefApp/Content.aspx/Bordeaux?N=4294966952&fromsearch=false&Ntk=All&Ntt=red&Ntx=mode%2bmatchallpartial
Using the URL Optimization API, you can move parameters into the path-params section of the URL. For example, the following URL includes the N and Ntt parameters in the base URL:
http://localhost/ContentAssemblerRefApp/Content.aspx/Bordeaux/_/N-4294966952/Ntt-red?fromsearch=false&Ntk=All&Ntx=mode%2bmatchallpartial
Note
To ensure the best possible natural search-engine ranking, it is recommended that you limit the number of parameters you include in the path-params section.
In order to shorten URLs, the Assembler API allows base-36 encoding of parameters.
For example, the following URL for Region > Napa contains the dimension value ID for Napa (4294966952):
http://localhost/ContentAssemblerRefApp/Content.aspx/Napa/_/N-4294966952
By base-36 encoding the N parameter, you can shorten the URL:
http://localhost/ContentAssemblerRefApp/Content.aspx/Napa/_/N-1z141pk
In order to simplify the URLs, session-scope parameters should be removed from the URL string and stored as session objects. This might include any parameters that do not change value during the session, such as the session ID or MDEX host and port values.
You can add non-parameters to URLs by passing them through the API.
In order to create directory-style URLs, you can limit the number of parameters in the query string by configuring a list of parameters to move from the query string and into the path-params section of the URL.
You must create a URL configuration file before completing this procedure.
To move parameters out of the query string and into the path-params section of the URL:
In your URL configuration file, locate the top-level URL formatter.
For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <property name="defaultEncoding"> <value>UTF-8</value> </property> <property name="pathSeparatorToken"> <value>_</value> </property> <!-- additional elements deleted from this example --!> </bean>
For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <property name="pathParamKeys"> </property> </bean>
Add a
list
attribute containing all of the parameters you want moved from the query string.For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <property name="pathParamKeys"> <list> <value>R</value> <value>A</value> <value>An</value> </list> </property> </bean>
You can apply base-36 encoding to numeric parameters.
You must create a URL configuration file before completing this procedure.
Only the numeric parameters can be encoded:
The following procedure provides instructions for applying base-36
encoding to the
An
parameter. You can apply base-36 encoding to any
numeric parameter, but each parameter requires a separately configured
paramEncoder
bean.
To encode numeric parameters:
Create a
paramEncoder
bean to invoke thecom.endeca.soleng.urlformatter.seo.SeoNavStateEncoder
:For example:
<bean name="An-paramEncoder" class="com.endeca.soleng.urlformatter.seo.SeoNavStateEncoder"> </bean>
Add a
paramKey
property to specify which numeric parameter to encode.For example:
<bean name="An-paramEncoder" class="com.endeca.soleng.urlformatter.seo.SeoNavStateEncoder"> <property name="paramKey"> <value>An</value> </property> </bean>
Repeat steps one and two for each parameter you want to encode.
Locate the top-level URL formatter bean in your URL configuration file.
For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> </bean>
Add a
urlParamEncoders
property:<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <property name="urlParamEncoders"> </property> </bean>
Add a
list
attribute and specify each of the parameter encoder beans.For example:
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter"> <property name="urlParamEncoders"> <list> <ref bean="N-paramEncoder"/> <ref bean="Ne-paramEncoder"/> <ref bean="An-paramEncoder"/> </list> </property> </bean>
In order to simplify the URLs, session-scope parameters should be removed from the URL string and stored as session objects.
This might include any parameters that do not change value during the session, such as the session ID or MDEX host and port values. For example, the following URL contains information about the MDEX host and port:
http://localhost:8888/endeca_jspref/controller.jsp?N=0&eneHost=localhost&enePort=15002
You can remove the MDEX host and port values from the URL and store them as session objects. The resulting URL is simplified:
http://localhost:8888/endeca_jspref/controller.jsp
The following procedure provides instructions for removing the MDEX host and port values from the URL, but this procedure can be adapted as necessary to remove other session-scope parameters.
To remove the MDEX host and port values from the URL and store them as session attribute values:
You can add non-parameters to URLs by passing them through the API.
For example, you could add information about how many records per page should display in each results set:
In the reference application's
controller.jsp
file, find the following section:
UrlState baseUrlState = urlFormatter.parseRequest(request); ENEQuery usq = queryBuilder.buildQuery(baseUrlState);
and add code similar to the following:
baseUrlState.setParam("records_per_page", "25");
Note
Oracle recommends limiting the number of parameters that display in URLs. It is recommended that session-scope parameters be removed from the URL and stored as session objects.