on 09-04-2009 10:34 AM
Hi everybody,
I'd be grateful if you could advise me on how to treat this problem :
I found many discussion about cookies manipulation with application running on NW7 (nw2004s) or later ... but there isn't any clear response ...(I'm not expert in WDJ development)
1- SAP WDJ methods are no more available with version NW7 (NW2004S) ? ( true or false?)
2- No possibility to use Java standards methods to manipulate cookies in WDJ application ? (create/read)
Thanks a lot
Hi,
You can use this code below:
HttpServletResponse httpServletResponse = (HttpServletResponse) TaskBinder.getCurrentTask().getProtocolAdapter().getResponseObjectInternal().getProtocolResponse();
Cookie testCookie = new Cookie("testCookie", "testValue");
httpServletResponse.addCookie(testCookie);
HttpServletRequest httpServletRequest = (HttpServletRequest) TaskBinder.getCurrentTask().getProtocolAdapter().getRequestObjectInternal().getProtocolRequest();
Cookie[] cookies = httpServletRequest.getCookies();
if (null != cookies) {
for (int i = 0; i < cookies.length; i++) {
String cookieName = cookies<i>.getName();
String cookieValue = cookies<i>.getValue();
if ("testCookie".equals(cookieName)) {
wdComponentAPI.getMessageManager().reportSuccess("Cookie: [testCookie] " + cookieValue);
}
}
}
As said before, WD does not "expose" the Request / Response objects. It expose it's "own" implementation, which uses the Request object but blocks most functions. Personally, I do not see a good reason to not allow a developer to use Cookies.
You will need to add the servlet.jar to your Project Build-Path. Right click the Project, -> Properties -> Java Build-Path -> Add Variable -> Select SAP_SYSTEM_ADD_LIBS -> Extend -> comp/SAP-JEE/DCs/sap.com/servlet... go all the way down!
Hope it helps,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
I have used following code
IResponse responseObj = ((IProtocolAdapter) WDProtocolAdapter.getProtocolAdapter()).getResponseObjectInternal();
HttpServletResponse response = (HttpServletResponse)responseObj.getProtocolResponse();
but the response variable is coming as null.
Could you please help me to resolve this issue.
Regards,
Anupama
WebDynpro abstracts the presentation from the view you create via a meta model.
So even if you only develop web based software, the framework doesn't expect to be running in a browser environment. Thats why everything you normally use (session, HTML/JS includes, cookies) wont work in WD4J.
You may find clues that describe how to hack some issues, but I strongly advise not to. Learn how to do things the SAP/WD4J way or choose a different framework instead ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.