I need to access the Manager from the servlet (or filter) in Tomcat to load the custom session by custom session ID.
Answering your next question: why do I need it. There's an old bug in Flash that causes it to send cookies from IE and not from the current browser. So, if I'm in FF and I'm trying to upload the file with SWFUpload I end up with the wrong session and an error.
I want to add the magic parameter to POST that should override the default (wrong) session id, then load the custom session instead of one loaded by Tomcat. I can't use URL rewriting since cookies are resolved first, and when flash sends wrong cookie from IE, Tomcat doesn't try to load the session from url-rewritten address.
I'd appreciate any other hint how to access Manager from context or a solution of the original problem.
Thanks in advance, Juriy
for Tomcat:
ApplicationContextFacade appContextFacadeObj = (ApplicationContextFacade) request.getSession().getServletContext();
try
{
Field applicationContextField = appContextFacadeObj.getClass().getDeclaredField("context");
applicationContextField.setAccessible(true);
ApplicationContext appContextObj = (ApplicationContext) applicationContextField.get(appContextFacadeObj);
Field standardContextField = appContextObj.getClass().getDeclaredField("context");
standardContextField.setAccessible(true);
StandardContext standardContextObj = (StandardContext) standardContextField.get(appContextObj);
Manager persistenceManager = standardContextObj.getManager();
}
catch(SecurityException e)
{
logger.error(e);
}
catch(NoSuchFieldException e)
{
logger.error(e);
}
catch(IllegalArgumentException e)
{
logger.error(e);
}
catch(IllegalAccessException e)
{
logger.error(e);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With