Here is sample code :
String serverName=request.getServerName();
String domainName=serverName.indexOf(".")!=-1? (serverName.substring(serverName.indexOf("."))):serverName;
String ltpaTokenCookie="";
Cookie cokkies[]=request.getCookies();
//retrieving ltpatoken cookie info and forming the ltpatoken cookie string
for(Cookie cookie:cokkies) {
if(cookie.getName().equalsIgnoreCase("LTPATOKEN")) {
ltpaTokenCookie=cookie.getName()+"="+cookie.getValue()+((cookie.getMaxAge()>0) ? "; expires=" + cookie.getMaxAge():"") +("; Domain=" + domainName);
break;
}
}
URLConnection docConnection = new URL(inputDocumentURL).openConnection();
docConnection.setRequestProperty("Cookie", ltpaTokenCookie);
String serverName=request.getServerName();
String domainName=serverName.indexOf(".")!=-1? (serverName.substring(serverName.indexOf("."))):serverName;
String ltpaTokenCookie="";
Cookie cokkies[]=request.getCookies();
//retrieving ltpatoken cookie info and forming the ltpatoken cookie string
for(Cookie cookie:cokkies) {
if(cookie.getName().equalsIgnoreCase("LTPATOKEN")) {
ltpaTokenCookie=cookie.getName()+"="+cookie.getValue()+((cookie.getMaxAge()>0) ? "; expires=" + cookie.getMaxAge():"") +("; Domain=" + domainName);
break;
}
}
URLConnection docConnection = new URL(inputDocumentURL).openConnection();
docConnection.setRequestProperty("Cookie", ltpaTokenCookie);
No comments:
Post a Comment