One way to validate OAF session in custom jsp/servlet in Oracle applications. Method will return "INVALID" if the current session is invalid, "EXPIRED" if current session is expired and "VALID" if current session is valid.
You can also create new session if current session is invalid, wiill post detail in some other post. But, usually if Functionality is part of existing oracle application module, then you will just want to validate if current session is valid or not. If not, you may want to redirect to /OA_HTML/AppsLocalLogin.jsp page.
public static String validateOAFSession(HttpServletRequest request, HttpServletResponse response) {
WebAppsContext appsContext = null;
try {
appsContext = WebRequestUtil.createWebAppsContext(request, response);
if (appsContext != null) {
String sessionCookie = WebRequestUtil.getSessionCookie(request, response, appsContext);
if (sessionCookie == null) {
return "INVALID";
}
if (!appsContext.validateSession(sessionCookie, true)) {
return "EXPIRED";
}
}
} catch (IOException ioe) {
return "INVALID";
} finally {
if (appsContext != null) {
appsContext.freeWebAppsContext();
}
}
return "VALID";
}
You can also create new session if current session is invalid, wiill post detail in some other post. But, usually if Functionality is part of existing oracle application module, then you will just want to validate if current session is valid or not. If not, you may want to redirect to /OA_HTML/AppsLocalLogin.jsp page.
public static String validateOAFSession(HttpServletRequest request, HttpServletResponse response) {
WebAppsContext appsContext = null;
try {
appsContext = WebRequestUtil.createWebAppsContext(request, response);
if (appsContext != null) {
String sessionCookie = WebRequestUtil.getSessionCookie(request, response, appsContext);
if (sessionCookie == null) {
return "INVALID";
}
if (!appsContext.validateSession(sessionCookie, true)) {
return "EXPIRED";
}
}
} catch (IOException ioe) {
return "INVALID";
} finally {
if (appsContext != null) {
appsContext.freeWebAppsContext();
}
}
return "VALID";
}