In portal we store the location of logged in user in a cookie and then read from the cookie everytime we change the tab.So as to avoid hitting the data base all the time.But the problem is- if the location contains special character in it ,then for that logged in user masthead diappears, because the special charactes are not read from cookie.
what code should i add to enable the special characters being read
Here is the code :-
strCookieName = "RUI_MyPurchLocAttr_" + strUserID.toUpperCase();
//Read RUI_MyPurchLocAttr coookie
HttpServletRequest requestHS = componentRequest.getServletRequest();
strLocationVal = myBeanName.getValue(requestHS,strCookieName);
HttpServletResponse respHS = componentRequest.getServletResponse(false);
if (strLocationVal.length() == 0){
//call ZMEP_GET_USERLOC
strLocationVal = myBeanName.getLocation(componentRequest,strUserID.toUpperCase());
//This check is to avoid writing cookie when error connection to backend
begin_index = strLocationVal.indexOf("[LOCATION]");
if (begin_index > -1)
{
//set in cookie "RUI_MyPurchLocAttr_<T#>"
myBeanName.setMyPCookieValue(respHS,strCookieName,strLocationVal,604800);
}
}
//strLDAPdata = strLocationVal;
begin_index = strLocationVal.indexOf("[LOCATION]");
end_index = strLocationVal.indexOf("[/LOCATION]");
if (begin_index > -1) {
strLocation = strLocationVal.substring(begin_index + 10, end_index);
}
begin_index = strLocationVal.indexOf("[LDAPDATA]");
end_index = strLocationVal.indexOf("[/LDAPDATA]");
if (begin_index > -1)
{
strLDAPdata = strLocationVal.substring(begin_index + 10, end_index);
}
strCookieName = "RUI_MyUserAttr_" + strUserID.toUpperCase();
//Read RUI_MyUserAttr_<T#> coookie strValidUser = myBeanName.getValue(requestHS,strCookieName);
if (strValidUser.length() > 0){
begin_index = strValidUser.indexOf("[SESSION_ID]");
end_index = strValidUser.indexOf("[/SESSION_ID]");
if (begin_index > -1) {
strSession = strValidUser.substring(begin_index + 12, end_index);
}javax.servlet.http.HttpSession objHS = requestHS.getSession();
strCurrSession = objHS.getId();
if (!strSession.equals(strCurrSession))
{
//call validuserstrValidUser = myBeanName.checkUser(componentRequest,strUserID.toUpperCase(),strLDAPdata);
myBeanName.setMyPCookieValue(respHS,strCookieName, strValidUser, 86400);
}
begin_index = strValidUser.indexOf("[DOES_NOT_EXIST]");
end_index = strValidUser.indexOf("[/DOES_NOT_EXIST]");
if (begin_index > -1) { strDoesNotExist = strValidUser.substring(begin_index + 16, end_index);
}
if (strDoesNotExist.equalsIgnoreCase("N")){
%>
window.location = "http://mypurchases.pg.com/MyPurchases/general/PilotSignup.html";
<%
}
}