So,I have to write my session control in the doProcess() method ? How do I have to configure my application so that every request goes through this filter ?
-- --------- Original Message --------- DATE: Fri, 10 Oct 2003 13:58:40 From: Carlos Sanchez <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>,<[EMAIL PROTECTED]> Cc: >You can extend RequestProcessor using a intercepting filter pattern for >preprocessing >(http://java.sun.com/blueprints/patterns/InterceptingFilter.html), so you >don't have to check the session in every jsp. > > > >public class MyRequestProcessor extends RequestProcessor { > > PreProcessingFilter firstPreProcessingFilter; > > public MyRequestProcessor() { > > firstPreProcessingFilter = > new SessionPreProcessingFilter( > new AuthenticationPreProcessingFilter(null)); > > } > > protected ActionForward processActionPerform( > HttpServletRequest request, HttpServletResponse response, > Action action, ActionForm form, ActionMapping mapping) throws > IOException, ServletException { > > ActionForward actionForward = firstPreProcessingFilter.process( > request, response, action, form, mapping); > > if (actionForward == null) { > return super.processActionPerform(request, response, action, > form, mapping); > } else { > return actionForward; > } > > } > >} > > > >/** > * A base clase for all preprocessing filters. Usually, concrete filters >only > * need to provide an implementation of <code>doProcess</code>. > */ >public abstract class PreProcessingFilter { > > private PreProcessingFilter nextFilter; > > public PreProcessingFilter(PreProcessingFilter nextFilter) { > this.nextFilter = nextFilter; > } > > /** > * Calls upon <code>doProcess</code>, and if necessary, continues to >call > * <code>process</code> on the next filter. > */ > public ActionForward process(HttpServletRequest request, > HttpServletResponse response, Action >action, > ActionForm form, > ActionMapping mapping) throws IOException, > ServletException { > > ActionForward actionForward = null; > > /* Process this filter. */ > actionForward = doProcess(request, response, action, form, mapping); > > /* Process next filter in the chain. */ > if ((actionForward == null) && (nextFilter != null)) { > return nextFilter.process(request, response, action, form, >mapping); > } else { > return actionForward; > } > > } > > /** > * Does the processing of this filter. > * > * @return <code>null</code> if the next filter must be processed; an > * <code>ActionForward</code> otherwise > */ > protected abstract ActionForward doProcess(HttpServletRequest request, > HttpServletResponse response, > Action action, ActionForm >form, > ActionMapping mapping) throws > IOException, ServletException, > InternalErrorException; >} > > > > > >> -----Mensaje original----- >> De: koen boutsen [mailto:[EMAIL PROTECTED] >> Enviado el: viernes, 10 de octubre de 2003 13:32 >> Para: Struts Users Mailing List >> Asunto: redirect problem >> >> >> Hi >> If my httpsession is invalid, I want to send the user to the >> logon page. I tried it in different ways, but get an error >> everytime I tried it like this : (sessionIsValid is a >> attribute in the session. If this attribute is null, it means >> that my session does no longer exist). >> >> >> <logic:notPresent name="sessionIsValid" scope="session"> >> <logic:forward name="/sessionTimedOut"/> </logic:notPresent> >> >> >> This is the error I get : >> javax.servlet.jsp.JspException: Exception redirecting for >> name /sessionTimedOut: java.lang.IllegalStateException >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R >> at >> org.apache.struts.taglib.logic.ForwardTag.doEndTag(ForwardTag. >> java:164) >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R >> at org.apache.jsp._specialCode1._jspService(_specialCode1.java:164) >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R >> at >> com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJs >> pBase.java:89) >> [10/10/03 13:08:25:033 CEST] 5355efea SystemErr R >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) >> [10/10/03 13:08:25:043 CEST] 5355efea SystemErr R >> at >> com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapp >> er.service(JspServlet.java:344) >> [10/10/03 13:08:25:043 CEST] 5355efea SystemErr R >> at >> com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile( >> JspServlet.java:598) >> [10/10/03 13:08:25:043 CEST] 5355efea SystemErr R >> >> Thanks for any help. >> >> Koen >> >> >> ____________________________________________________________ >> Get advanced SPAM filtering on Webmail or POP Mail ... Get >> Lycos Mail! http://login.mail.lycos.com/r/referral?aid=27005 >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > ____________________________________________________________ Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail! http://login.mail.lycos.com/r/referral?aid=27005 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]