From my understanding these requests are not made in the context of the logged in user. Being that the results are cached in a servlet, and userid is not one of the keys that is used,<br />
<br />
A url for the style sheet looks like this<br />
<br />
/wps/CacheProxyServlet/colorPalette/default/browserVendor/Mozilla+Foundation/browserName/Firefox/browserVersion/2.0/locale/en/forwardurl/wps/themes/html/IBM/./ styles.jsp<br />
<br />
Thus it is an unauthenticated request.<br />
<br>
IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0<br>
IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0<br>
<br>
The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

03-11-2008, 03:00 PM

unix

Re: access user attributes in styles_rules

You have to pass your information on the URL to the stylesheet. (You
would want to do that for proper cache partitioning anyway.)

Unfortunately, the cache proxy tag doesn't take parameters. So what you
have to do is get the url output of that tag in a variable and split the
string manually on some known key like /forwardurl/ and insert new
key/value pairs in the URL. The following code would go in head.jspf:

<portal-logic:urlFindInTheme file="./styles.jsp" id="stylesJspUrl" />
<c:set var="cssUrl" scope="request"><portal-core:cacheProxyUrl
forwardurl="<%=stylesJspUrl.toString()%>" /></c:set>
<%
// The <portal-core:cacheProxyUrl> tag does not support adding
// new parameters to the URL. So split the cache proxy url at
// the /forwardurl/ parameter to add more parameters.
// NOTE: It normally is not safe to assume the format of
// URLs returned by portal.
String cssUrl = (String)request.getAttribute("cssUrl");

Also, unfortunately, the servlet this URL calls does not know about your
parameters and won't pull them out of the URL and put them in the
request as attributes for you. So, you have to do that manually. The
following code would go in styles_rules.jspf:

// Parse parameters out of PathInfo... The CacheProxyServlet does
// this for attributes it knows about. So, since the servlet does
// not parse all of the parameters we need into the request,
// we have to re-parse the information here. This means that some
// parameters are parsed twice, but that is the only way to get
// all attributes.
//
// Since Styles.jsp is called as a result of a
// RequestDispatcher.forward(),
// the request.getPathInfo() method returns null and not the pathInfo
// passed to the CacheProxyServlet. We have to get that information
// out of a special request atribute named
// javax.servlet.forward.path_info.
boolean foundForwardURL = false;
String pathInfo =
(String)request.getAttribute("javax.servlet.forward.path_info");
if ( null != pathInfo )
{
java.util.StringTokenizer piTokenizer = new
java.util.StringTokenizer( pathInfo, "/" );
while ( piTokenizer.hasMoreTokens() && !foundForwardURL ) {
String param = null;
String value = null;

param = piTokenizer.nextToken();
if ( piTokenizer.hasMoreTokens() ) {
value = piTokenizer.nextToken();
} else {
// If we have a parameter without a value, the URL
// is malformed
throw new java.net.MalformedURLException( "parameter "
+ param + " did not have a value");
}

// Check for a forwardurl parameter. If this is one, the
// remainder of the path info is a URL so we need to stop
// tokenizing. Since the CacheProxyServlet already
// parsed this value and put it in the request, we can
// ignore the remainder of the path info.
if ( "forwardurl".equals( param ) ) {
foundForwardURL = true;
} else {
request.setAttribute( param, value );
}
}
}