मैं कुकी के अंदर यूनिकोड मान सेट करने की कोशिश कर रहा हूं लेकिन यह इसे स्वीकार नहीं करता है और अपवाद फेंकता है। मैंने स्ट्रिंग के हेक्साडेसिमल मान की जांच की है और यह सही है लेकिन एक कुकी में जोड़ने के दौरान अपवाद फेंकता है।java.lang.IllegalArgumentException: कुकी मूल्य या विशेषता में नियंत्रण चरित्र
private void fnSetCookieValues(HttpServletRequest request,HttpServletResponse response)
{
Cookie[] cookies=request.getCookies();
for (int i = 0; i < cookies.length; i++) {
System.out.println(""+cookies.length+"Name"+cookies[i].getName());
if(cookies[i].getName().equals("DNString"))
{
System.out.println("Inside if:: "+cookies[i].getValue()+""+cookies.length);
try {
String strValue;
strValue = new String(request.getParameter("txtIIDN").getBytes("8859_1"),"UTF8");
System.out.println("Cookie Value To be stored"+strValue);
for (int j = 0; j < strValue.length(); j++) {
System.out.println("Code Point"+Integer.toHexString(strValue.codePointAt(j)));
}
Cookie ck = new Cookie("DNString",strValue);
response.addCookie(ck);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
मैं:
java.lang.IllegalArgumentException: Control character in cookie value or attribute.
जब प्रतिक्रिया ऑब्जेक्ट को कुकी जोड़ने। मैं रनटाइम पर्यावरण के रूप में टोमकैट 7 और जावा 7 का उपयोग कर रहा हूं।
धन्यवाद यह काम करता है !! –
आपका स्वागत है। – BalusC