Jboss 5.1.0 を使用しています
私の Bean では、Response
オブジェクトを取得したいので、これを使用していくつかの値をcookie
.
以下はBeanの私のコードです、
HttpServletResponse response = null;
response = (HttpServletResponse) PolicyContext.getContext("javax.servlet.http.HttpServletResponse");
//Line number 1230
HttpServletRequest req = null;
req = (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
Cookie[] cookies = req.getCookies();
for(int i=0;i<cookies.length;i++)
{
if(cookies[i].getName().contains("myCookie"))
{
cookies[i].setValue("");
cookies[i].setPath("/");
cookies[i].setMaxAge(0);
response.addCookie(cookies[i]);
}
}
しかし、行番号1230で例外を下回っています
java.lang.IllegalArgumentException: No PolicyContextHandler for key=javax.servlet.http.HttpServletResponse
13:24:16,457 ERROR [STDERR] at javax.security.jacc.PolicyContext.getContext(PolicyContext.java:107)
13:24:16,457 ERROR [STDERR] at myPackage.myBean(myBean.java:1230)
13:24:16,457 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:24:16,457 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
13:24:16,457 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
13:24:16,457 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
13:24:16,457 ERROR [STDERR] at org.apache.el.parser.AstValue.invoke(AstValue.java:170)
13:24:16,457 ERROR [STDERR] at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
13:24:16,457 ERROR [STDERR] at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
13:24:16,457 ERROR [STDERR] at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
13:24:16,457 ERROR [STDERR] at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
13:24:16,457 ERROR [STDERR] at javax.faces.component.UICommand.broadcast(UICommand.java:387)
13:24:16,457 ERROR [STDERR] at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
13:24:16,457 ERROR [STDERR] at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
13:24:16,457 ERROR [STDERR] at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
オブジェクトを取得してrequest
いますが、オブジェクトではありませんresponse
。これを修正するには?