on 06-15-2005 2:32 PM
Hello,
Is there a way to use Cookies in Web DynPro like a regular Servlet uses in it's response Object?
If yes, I could use a code example...
Roy
Hi
You could use the Cookies class but it would be a non standard API for WebDynpro.
Code would be something like
Cookie[] cookies = request.getCookies();
String cookieName = SAPCookie;
String defaultValue = 1;
for ( int i=0; i<cookies.length; i++) {
Cookie cookie = cookies<i>;
if (cookieName.equals(cookie.getName()))
return(cookie.getValue());
}
return(defaultValue);
}
regards
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
10q Santhosh, 3 questions:
1. This will get a Request Object containing all the client's request data just like in a regular Servlet or does it have special considerations I should worry about?
2. Where do you recommend putting this statement? I assume at the wdDoInit() method right?
3. Is there a Response object I can create as well?
Roy
Hi Roy,
1. This will create a Request Objec containing all the client's request just like in a regular Servlet or does it have special considerations I should worry about?
A: If you have portal and webdynpro components, both have to use the same runtime. If you are using only webdynpro components then you can use the "Task" class. But it is a non-standard API.
Task.getCurrentTask().getWebContextAdapter().getHttpServletRequest()
2. Where do you recommend putting this statement? I assume at the wdDoInit() method right?
A: Don't put this statement in the doInit(), if you are handling some event within the component and refreshes the view, your doInit() will not get executed.
3. Is there a Response object I can create as well?
A:
HttpServletResponse response =((com.sap.tc.webdynpro.services.sal.adapter.core.IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletResponse()
Regards,
Santhosh.C
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.