Simplifying Portal URLs
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
When you create portals and portal desktops, the default URLs to the portal's books and pages contain parameters and elements you might want to eliminate to make shorter, simpler URLs. This topic shows you how to simplify your portal's URLs.
Figure 1 shows a sample default URL, and Figure 2 shows the same URL simplified.
Figure 1 Default URL: http://intranet/sampleportal/appmanager/myportal/mydesktop?_nfpb=true&_pageLabel=MyPage
Figure 2 Simplified URL: http://intranet/sampleportal/page/myportal/mydesktop/MyPage
This topic includes the following sections:
Note: This topic provides instructions for simplifying URLs generated on book and page clicks. It does not provide instructions on creating simplified URLs for links within your presentation JSPs.
The default URLs for books and pages are different for single portal files and streaming portal desktops (see Single File vs. Streamed Rendering in the Portal User Interface Framework Guide Overview).
Table 1 shows examples of default URLs for single portal files and streaming portal desktops, along with examples of simplified URLs.
The following steps show you how to create simpler URLs:
The portal framework ultimately needs the long URLs it generates. When you set up your URL simplifying mechanism, you need to tell the framework how to map your short URL to the long URL it needs. You set up this mapping in a servlet.
In this step you create a servlet called page
(page.jsp
) in the web application root. This page.jsp
handles the mapping between a simplified URL and a longer framework URL. You can name your servlet/JSP whatever you like.
Listing 1 New code for page.jsp
<%
String [] thePath= request.getPathInfo().split("/");
if (thePath[1].equals("portal"))
{
request.getRequestDispatcher("/" + thePath[2]
+ ".portal?_nfpb=true&_pageLabel=" +
thePath[3]).forward(request, response);
}
else
{
request.getRequestDispatcher("/appmanager/"
+ thePath[1] + "/" + thePath[2] +
"?_nfpb=true&_pageLabel=" +
thePath[3]).forward(request, response);
}
%>
The code splits the URL the servlet receives into pieces at each forward slash ("/"), detects whether the URL is for a single .portal
file or a streaming portal, and rearranges the simplified URL to become the longer URL the framework needs.
Now that you have created the servlet, you must tell the server about it with the following steps:
Listing 2 Servlet declaration entry
<servlet>
<servlet-name>page</servlet-name>
<jsp-file>page.jsp</jsp-file>
</servlet>
This entry tells the server that a servlet called page
exists, which is the page.jsp
file in the portal Web project root.
web.xml
, add the entry shown in Listing 3.Listing 3 Servlet-mapping entry
<servlet-mapping>
<servlet-name>page</servlet-name>
<url-pattern>/page/*</url-pattern>
</servlet-mapping>
This entry tells the server to use the page
servlet whenever a user clicks a URL containing /page/*
. You create URLs with this pattern in the following steps.
Users navigate through your portals with book and page links in a menu. The portal framework dynamically builds book and page links with menu skeleton files. In this step, you modify the menu skeletons to generate your new shorter URLs. These new URLs appear in the browser address field when users click the book and page links.
This step provides support for simplified URLs in both single-level and multi-level menus in the default skeleton.
Note: Any Look & Feel that uses the default skeleton—or at least the default submenu.jsp
and singlelevelmenu.jsp
skeleton files—supports the URL simplifying you implement in this step. But for any new skeletons you use in a Look & Feel that have their own submenu.jsp
and singlelevelmenu.jsp
files, you must repeat this step for those skeletons as well. For more information on skeletons, see Creating Skeletons and Skeleton Themes in the WebLogic Workshop help system.
The singlelevelmenu.jsp
skeleton file generates links to top-level books and pages. In this procedure, you modify the singlelevelmenu.jsp
file in the default skeleton.
<portalWebProject>/framework/skeletons/default/singlelevelmenu.jsp
.
com.bea.netuix.servlets.manager.AppContext
BookPresentationContext book = BookPresentationContext.getBookPresentationContext(request);
Directly above that line, paste the code in Listing 4.
Listing 4 Code to Split the Request URI
String shortpath = "";
String [] path = request.getRequestURI().split("[/.]");
if (AppContext.getAppContext(request).isDotPortal())
{
shortpath = request.getContextPath() + "/page/" + path[3] + "/" + path[2] +
"/";
}
else
{
shortpath = request.getContextPath() + "/page/" + path[3] + "/" + path[4] +
"/";
}
The code splits the URI into pieces at each forward slash and dot ("[/.]"), detects whether the URL is for a single .portal
file or a streaming portal, and rearranges the URL to use the simplified format. For example, for a .portal
file called sample.portal
, the split creates pieces called sample
and portal
, and the new simplified URL reassembles those pieces as portal/sample
. The simplified URL is assigned to the variable shortpath
.
Listing 5 Code block from singlefilemenu.jsp
else
{
if (inactiveImage == null)
{
%><li class="<%= menuItemClass %>"><a href="<render:pageUrl pageLabel="<%=
"><%= pageCtx.getTitle() %></a></li><%
pageCtx.getDefinitionLabel() %>"/>
}
else if (rolloverImage == null)
{
%><li class="<%= menuItemClass %>"><a href="<render:pageUrl pageLabel="<%=
"><img src="<%= inactiveImage %>"></a>
pageCtx.getDefinitionLabel() %>"/>
</li><%
}
else
{
%><li class="<%= menuItemClass %>"><a href="<render:pageUrl pageLabel=
"><img src="<%= inactiveImage
"<%= pageCtx.getDefinitionLabel() %>"/>
%>" longDesc="<%= rolloverImage %>"></a></li><%
}
}
This code generates links for books and pages that use images, rollover images, or text for navigation.
href
values, highlighted in Listing 5, with the following code:<%= shortpath + childPageCtx.getDefinitionLabel() %>
The submenu.jsp
skeleton file generates the links to books and pages below the top-level book and page links. In this procedure, you modify the submenu.jsp
file in the default skeleton. Modifying the submenu.jsp
skeleton file is almost identical to modifying singlelevelmenu.jsp
in the previous procedure.
<portalWebProject>/framework/skeletons/default/submenu.jsp
.
com.bea.netuix.servlets.manager.AppContext
if (!bookCtx.isHidden()
Directly above that line, paste the code in Listing 6.
Listing 6 Code to Split the Request URI
String shortpath = "";
String [] path = request.getRequestURI().split("[/.]");
if (AppContext.getAppContext(request).isDotPortal())
{
shortpath = request.getContextPath() + "/page/" + path[3] + "/" + path[2] +
"/";
}
else
{
shortpath = request.getContextPath() + "/page/" + path[3] + "/" + path[4] +
"/";
}
Listing 7 Code block from submenu.jsp
<a class="<%= menuItemLinkClass %>" href="<%=PageURL.createPageURL(request, response, childPageCtx.getDefinitionLabel()).toString() %>"><%=childPageCtx.getTitle() %></a>
href
value, highlighted in Listing 7, with the following code:<%= shortpath + childPageCtx.getDefinitionLabel() %>
The portal framework uses book and page Definition Labels in the book and page URLs rather than the book and page Titles your visitors see. That means the book or page Definition Label appears in the Web browser address bar when a visitor clicks that book or page.
For example, a user sees a page called My Page (the Title), but when the user clicks My Page, the URL in the address bar ends with /page_2 (the Definition Label). Change your Definition Labels to the text you want to appear for the book/page name in the URL.
Note: You cannot use spaces or special characters in Definition Labels.
Figure 3 Page Title and Definition Label
You can also create a streaming portal desktop using your portal file as a template in the WebLogic Administration Portal. After you create the desktop, view it and navigate among the books and pages to see the simplified URLs.
For instructions, see Create a Desktop in the WebLogic Administration Portal help system.
![]() |
![]() |
![]() |