jp.terasoluna.fw.web.struts.actions
Class MakeSessionDirectoryAction

java.lang.Object
  extended by org.apache.struts.action.Action
      extended by jp.terasoluna.fw.web.struts.actions.ActionEx
          extended by jp.terasoluna.fw.web.struts.actions.MakeSessionDirectoryAction

public class MakeSessionDirectoryAction
extends ActionEx

Action that creates session directory.

Session directory is a temporary directory to save the files (PDF etc.) generated at server side. This action creates session directory for each logon user.

To use this function, it is necessary to specify the session directory path in the system configuration property file(system.properties).

Settings of system configuration property file (system.properties)
session.dir.base=/tmp/sessions
Session directory can be created with the following two methods.

(1)Use MakeSessionDirectoryAction class
Transit to the MakeSessionDirectoryAction after the successful login.
Forward to the destination specified in the parameter attribute of action property in struts-config.xml.
The settings of struts-config.xml and Bean definition file are as follows.
Settings of struts-config.xml
 <action path="/makeSessionDir"
     scope="session"
     parameter="/foo.jsp">;
 </action>
 
Settings of Bean definition file
 <bean name="/makeSessionDir" scope="prototype"
   class="jp.terasoluna.fw.web.struts.actions.MakeSessionDirectoryAction">
 </bean>
 
(2)Create session directory directly in the action class
In the action other than MakeSessionDirectoryAction, it is necessary to call FileUtil#makeSessionDirectory(String sessionId) at a location where HttpSession can be fetched after the user login.


Session directory can be deleted with the following method.

(1)Use HttpSessionListener implementation class
Register the HttpSessionListener implementation class as a listener in the deployment descriptor(web.xml). When the session is cancelled, implement the process that deletes session directory(FileUtil#removeSessionDirectory(String sessionId)) in the listener.
The settings of web.xml are as follows.
Settigns of deployment descriptor(web.xml)
 <web-app>
   ...
   <listener>
     <listener-class>
       jp.terasoluna.fw.web.MyHttpSessionListener
     </listener-class>
   </listener>
 </web-app>
 


Field Summary
private static java.lang.String FORWARD_ERRORPAGE_ERROR
          Error page(404) Error code indicating the transition failure.
private static org.apache.commons.logging.Log log
          Log class.
private static java.lang.String SESSION_NOT_FOUND_ERROR
          Error code indicating the failure to fetch the session.
 
Fields inherited from class jp.terasoluna.fw.web.struts.actions.ActionEx
FORWARD_TXTOKEN_ERROR
 
Fields inherited from class org.apache.struts.action.Action
defaultLocale, servlet
 
Constructor Summary
MakeSessionDirectoryAction()
           
 
Method Summary
 org.apache.struts.action.ActionForward doExecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
           Generates the session directory.
When it is possible to fetch the session, it creates the session directory, returns the action forward set with the value (destination page) of "Parameter" attribute.
When the "parameter" attribute is not set, returns the error (404).
Generates system exception when unable to fetch the session.
 
Methods inherited from class jp.terasoluna.fw.web.struts.actions.ActionEx
addErrors, addMessages, execute, isSaveToken, isTokenCheck, processTokenCheck, setSaveToken, setTokenCheck
 
Methods inherited from class org.apache.struts.action.Action
addErrors, addMessages, execute, generateToken, getDataSource, getDataSource, getErrors, getLocale, getMessages, getResources, getResources, getServlet, isCancelled, isTokenValid, isTokenValid, resetToken, saveErrors, saveErrors, saveErrors, saveMessages, saveMessages, saveToken, setLocale, setServlet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log class.


SESSION_NOT_FOUND_ERROR

private static final java.lang.String SESSION_NOT_FOUND_ERROR
Error code indicating the failure to fetch the session.

See Also:
Constant Field Values

FORWARD_ERRORPAGE_ERROR

private static final java.lang.String FORWARD_ERRORPAGE_ERROR
Error page(404) Error code indicating the transition failure.

See Also:
Constant Field Values
Constructor Detail

MakeSessionDirectoryAction

public MakeSessionDirectoryAction()
Method Detail

doExecute

public org.apache.struts.action.ActionForward doExecute(org.apache.struts.action.ActionMapping mapping,
                                                        org.apache.struts.action.ActionForm form,
                                                        javax.servlet.http.HttpServletRequest req,
                                                        javax.servlet.http.HttpServletResponse res)

Generates session directory.
When it is possible to fetch the session, it creates the session directory, returns the action forward set with the value (destination page) of "Parameter" attribute.
When the "parameter" attribute is not set, returns the error (404).
Generates system exception when unable to fetch the session.

Specified by:
doExecute in class ActionEx
Parameters:
mapping - Action mapping
form - Action form
req - HTTP request
res - HTTP response
Returns:
Action forward.