Servlet Filter - Reading Request Error

I have a servlet filter that sits in front of a webservice servlet (AXIS) - what I want the filter to do is to look at the content of the ServletRequest and if a particular string is located in the request, I want to call another service. Everything works just fine except (isin't there always an execept) that when I execute the following code in the filter:
BufferedReader inReader = request.getReader();
String line = null;
StringBuffer sbuf = new StringBuffer();
// Read the current request into a buffer
while((line = inReader.readLine()) != null) {
sbuf.append(line);
sbuf.append("\n\r");
if (sbuf.toString().indexOf("mystring") > -1) {
// I do some code
} else {
chain.doFilter(request, wrapper);
When I execute this code, at the chain.doFilter I get an "java.lang.IllegalStateException: getReader() has already been called for this request"
I know that this is because I obtained the Reader from the request. But my question is - How can I look at the request string so that I can evaluate it and not have this exception thrown..
Thx in advance...

My guess is that when you do the chain.doFilter you pass the request to another resource that then tries to access the request.getInputStream method.
From the JavaDocs:
getReader
public java.io.BufferedReader getReader()
throws java.io.IOException
Retrieves the body of the request as character data using a BufferedReader. The reader translates the character data according to the character encoding used on the body. Either this method or getInputStream() may be called to read the body, not both.
Returns:
a BufferedReader containing the body of the request
Throws:
java.io.UnsupportedEncodingException - if the character set encoding used is not supported and the text cannot be decoded
IllegalStateException - if getInputStream() method has been called on this request
java.io.IOException - if an input or output exception occurred

Similar Messages

  • Null query string in servlet filter with OC4J 10.1.3.1.0

    I have a strange problem with OC4J 10.1.3.1.0. In the servlet filter, while requesting the querystring with HttpServletRequest.getQueryString the result is null, even if it is verified with a sniffer that that query string is there. This happens only with certain requests. The query string is long but nothing very special otherwise.
    Any ideas what might be wrong?
    Thanks,
    Mika

    I got the same problem. I tried in others application servers alternatives and it works. By now i have to change links like this "http://localhost:8888/SIVIUQ/LoadIndex.portal?test=1" for forms using javaScript to send the parameters corresponding to the button pressed. To use buttons instead links is not the better solution due to usability. Any suggestion to solve this problem?
    Thanks
    Javier Murcia
    Yo tengo el mismo problema. He intentado con otros servidores de aplicaciones y funciona. Por ahora tengo que cambiar links como "http://localhost:8888/SIVIUQ/LoadIndex.portal?test=1" por formularios, usando javaScript para enviar los parametros correspondientes al boton presionado. Usar botones en vez de links no es la mejor solucion debido a usabilidad. ¿Alguna sugerencia para resolver este problema?
    Gracias
    Javier Murcia

  • PhaseListener or servlet filter?

    I have tried reading through all the posts dealing with site authentication and redirection to a login page if a user is not logged in or has a timed-out session.
    I found that there seems to be two main approaches and that is to use either a PhaseListener or a servlet filter but I can't tell which is better.
    So before I start down one of these two alleys I just wanted to get some opinions as to which is better. Which approach do you use and why is it better?

    If your application does not use any other servlets the phase listener is better because its binded with jsf and you have faces context instance. Otherwise if your application use servlets that is not the faces servlet (i.e. servlet
    for ajax or something like that) then use servlet filter.

  • Error :Unable to retrieve data from iHTML servlet for Request2 request

    I open bqyfile to use HTML in workspace.
    When I export report to excel in IR report.
    Then I press "back" button I get error"Unable to retrieve data from iHTML servlet for Request2 request "
    And I can not open any bqyfiles in workspace.
    Anybody gat the same question? Thanks~

    Hi,
    This link will be helpful, the changes is made in the TCP/IP parameter in the registry editor of Windwos machine. I tried the 32 bit setting for my 64 bit machine (DWORD..) and it worked fine for me..
    http://timtows-hyperion-blog.blogspot.com/2007/12/essbase-api-error-fix-geeky.html
    Hope this helps..

  • Request.setHeader in servlet filter

    Hi there,
    I am working on servlet filter to filter HttpServletRequest before sending it to the original servlet.
    The original servlet expects some content posted in the body of HttpServletRequest object.
    In my servlet filter, I need to modify this content (already done) and then doFilter to the origin.
    And here is the problem:
    The original servlet uses HTTP header's content-length value to read the entire content posted. But if I modify this content in my filter, it will never get correct content of the request.
    Unfortunately the original servlet is black boxed and there is no way to modify it.
    Is there any way to modify HTTP headers of HttpServletRequest in servlet filter?
    Thank you for any suggestions,
    mato_v

    Hum... ServletRequest.getHeader is read only, so you can't change them. There few solution you may try though:
    * Try create another wrapper instance of ServletRequest inside your filter and forward it to your black box servlet. You might have to wrote your own implementation to manipulate those Headers.
    * How about after you changed your data, redirect/post to your black box with the correct content? Use java.net.HttpURLConnection or a java Http client to do fancy posting if needed.
    Hope these helps.

  • Error:SOAP: response message contains an error XIAdapter/PARSING/ADAPTER.SOAP_EXCEPTION - soap fault: Server was unable to read request. --- There is an error in XML document (1, 447). --- Input string was not in a correct format.

    Hi All,
        We have a scenario of FTP-->PI---> Webservice.  While triggering the data in the FTP, it is failing in the PI with the below error
    SOAP: response message contains an error XIAdapter/PARSING/ADAPTER.SOAP_EXCEPTION - soap fault: Server was unable to read request. ---> There is an error in XML document (1, 447). ---> Input string was not in a correct format.
    Can you please help?

    Hi Raja- It seems to be a data quality issue.
    Check for the value @ 1447 position in the xml message that you are trying to send to web service..
    may be a date filed/decimal value which is not in expected format.

  • Please Help!!! Deployment failure error Jps servlet filter creation failed.

    Hello All,
    We are trying to move from 10g to Jdev 11g. We are in the process of deploying the WAR application to weblogic server. However, we keep getting one error after another. This is the latest one:
    [12:40:02 PM] [Deployer:149193]Operation 'deploy' on application 'webapp1' has failed on 'AdminServer'
    [12:40:02 PM] [Deployer:149034]An exception occurred for task [Deployer:149026]deploy application webapp1 on AdminServer.: JPS-00063: Jps servlet filter creation failed. Reason: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.security.PrivilegedActionException: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsPlatformFactory...:oracle.security.jps.JpsRuntimeException:JPS-00063: Jps servlet filter creation failed. Reason: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.security.PrivilegedActionException: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsPlatformFactory....
    [12:40:02 PM] Weblogic Server Exception: weblogic.application.ModuleException: JPS-00063: Jps servlet filter creation failed. Reason: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.security.PrivilegedActionException: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsPlatformFactory...:oracle.security.jps.JpsRuntimeException:JPS-00063: Jps servlet filter creation failed. Reason: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.security.PrivilegedActionException: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsPlatformFactory...
    [12:40:02 PM] See server logs or server console for more details.
    [*12:40:02 PM] weblogic.application.ModuleException: JPS-00063: Jps servlet filter creation failed. Reason: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.security.PrivilegedActionException: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsPlatformFactory...:oracle.security.jps.JpsRuntimeException:JPS-00063: Jps servlet filter creation failed. Reason: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.security.PrivilegedActionException: oracle.security.jps.JpsException: JPS-00065: Jps platform factory creation failed. Reason: java.lang.ClassNotFoundException: oracle.security.jps.wls.JpsWlsPlatformFactory...*[12:40:02 PM] Deployment cancelled.
    I am sorry to have made the post title so eye catching, but we keep getting issues, one after the other and we are fast approaching the deadline for this upgrade. Thanks for being understanding.
    Please help!!!
    Edited by: user12054715 on Aug 29, 2011 7:16 PM

    UPDATE:
    I have been trying to find the class JpsWlsPlatformFactory and some sites say that it is present in the jar - jps-api.jar. So I looked in D:\Oracle\Middleware\oracle_common\modules\oracle.jps_11.1.1 and found a jar called jps-api.jar but the class JpsWlsPlatformFactory was not there. I also tried to find this class on the web but no success.
    This is very wierd that oracle.security.jps.wls.JpsWlsPlatformFactory is nowhere to be found on the internet!!!
    NOTE: Our application is based on JSF/ADF.
    Please help!
    Edited by: user12054715 on Aug 29, 2011 9:43 PM

  • Error reading request connection reset

    hello,
    i am facing this error(Error reading request connection reset) when i press the submit button of the JSP file. This JSP is a sign-in page consisting of 6 fields and the "submit" button. Data is to be checked first then entered to the database....
    If anyone can help, please reply as soon as possible

    The workaround for this is to change the browser settings. The browser can be configured to communicate with a proxy server in two ways. The first method is
    to manually provide the URL of the proxy server for the browser to talk to. The other way is to provide a Java Script file with a .pac extension to tell the browser
    what proxy to communicate with. In either case the browser can be told to ignore the proxy for calls made to certain URI which could also be on the local
    machine or in the same subnet.
    The Exception that Tomcat throws occurs when the browser is directed to contact the server directly without going through the proxy. This exception does not
    occur if the browser is set to use the proxy for all types of URI.
    This can be done in two ways:
    1. Manually:
    a. For Netscape Browser : Go to Edit-preferences-Advanced-Proxies, select manual, click the view button, enter the appropriate proxy entry into each of the
    boxes, Leave the "No Proxy for:" entry blank.
    b. For Internet Explorer : Go to tools-internet options, click on the connections tab, click on LAN settings button, Check the use proxy server option, Enter the
    appropriate proxy URL and port number, Uncheck the "Byepass proxy for local addresses" option
    2. Automatic: Through the .pac file
    a. For Netscape:
    function FindProxyForURL(url, host) {
    return "PROXY_URL_1", "PROXY_URL_2", ... ;
    b. For Internet Explorer:
    function FindProxyForURL(url, host) {
    return "PROXY_URL_1", "PROXY_URL_2", ... ;
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • Managed session bean in servlet filter

    Hi,
    Is there a way to get hold of a managed bean with session scope in a servlet filter? The code below throws an error due to the fact that the faces context is null.
    FacesContext facesContext = FacesContext.getCurrentInstance();
    System.out.println("facesContext: " + facesContext); // shows that facesContext is null
    ApplicationFactory appFactory = ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    Application app = appFactory.getApplication();
    Object obj = app.createValueBinding("user").getValue(facesContext); //throws the error due to the null parameter
    Object obj2 = app.createValueBinding("user"); //results in a valid ValueBindingHere is the faces-config snippet for the managed bean:
    <managed-bean>
        <managed-bean-name>user</managed-bean-name>
        <managed-bean-class>biz.libereco.skemo.info.asl.beans.User</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>For the record, I am using JSF 1.0 Final.
    Thank you,
    Marcel

    wynton_0 wrote:
    Yes, there is a way to get hold of a managed bean with session scope in a servlet filter.
    See here:
    [http://wiki.apache.org/myfaces/AccessFacesContextFromServlet]
    and here:
    [how to access faces context and backing beans in a servlet filter|http://www.thoughtsabout.net/blog/archives/000033.html]
    This makes no utter sense. A JSF session scoped managed bean is under the hood just put as a HttpSession attribute with the managed bean name as key. Guess what, you can just access the HttpSession in Filter by ((HttpServletRequest) request).getSession() and then just call getAttribute() on it. If it isn't there yet, then just do a setAttribute() with a new instance.
    After I get User bean in my Servlet filter, I populate value to this bean, for example:
    user.setLanguage(request.getParameter("locale"));
    The User bean is in session scope. The User bean's language attribute suppose to be same in the whole session scope, but later on, I got null. My question is:
    how to keep this value in session scope?The the session was apparently invalidated/renewed or you manually removed the bean or replaced it by null.
    In the future, please don't resurrect old topics, just start a new topic for each independent problem/question.

  • Weblogic.utils.NestedRuntimeException when using javax.servlet.Filter

    IDE: JDev 10gR3.4 & JDev 11gR2.3
    ViewController technology: JSF/ADF Faces
    Example code flow:
    Run page2.jsf
    MyFilter intercepts request, checks for parameter on session.
    If parameter not null, goto page2.jsf
    Else redirect to page1.jsf
    page1.jsf has a button that sets the value on the session scope after clicking.
    In jdev 11gR2.3, I get an weblogic.utils.NestedRuntimeException after clicking the button on page1.jsf. This error does not occur in jdev 10gR3.5. Although the application continues to execute and proper info is displayed, I’m wondering why this occurs and also if I should be concerned. Has anyone experienced a similar issue when using javax.servlet.Filter in 11g?
    MyFilter code snipet:
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) {
            try {
                HttpServletRequest httpRequest = (HttpServletRequest)servletRequest;
                HttpServletResponse httpResponse = (HttpServletResponse)servletResponse;
                String redirect = httpRequest.getContextPath() + "/faces/page1.jsf"; //only difference here is 11g uses jsf, 10g uses jsp.
                String uri = httpRequest.getRequestURI().toString();
                Boolean mySessionAttribute = (Boolean)httpRequest.getSession().getAttribute("MYSESSIONATTRIBUTE");
                if (uri.endsWith(redirect) || mySessionAttribute != null) {
                    filterChain.doFilter(servletRequest, servletResponse);
                } else {
                    httpResponse.sendRedirect(redirect);
                    return;
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ServletException e) {
                e.printStackTrace();
    page1.jsf/jsp
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
        <h:form id="f1">
            <h:commandButton value="Submit" id="cb1" action="#{Page1Bean.clicked}" type="submit"/>
        </h:form>
    </f:view>page2.jsf/jsp
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
        <af:document title="main.jsf" id="d1">
            <af:form id="f1">
                <af:outputText value="This is the main content" id="ot1"/>
            </af:form>
        </af:document>
    </f:view>Page1Bean.java
    public class Page1Bean {
        public void clicked() {       
            FacesContext context = FacesContext.getCurrentInstance();
            ExternalContext externalContext = context.getExternalContext();
            externalContext.getSessionMap().put("MYSESSIONATTRIBUTE", Boolean.TRUE);
            try {
                externalContext.redirect("/11gFilterExample-ViewController-context-root/faces/page2.jsf");
            } catch (IOException e) {
                    e.printStackTrace();
    }Full exception
    weblogic.utils.NestedRuntimeException: Cannot parse POST parameters of request: '/11gFilterExample-ViewController-context-root/faces/page1.jsf'
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.mergePostParams(ServletRequestImpl.java:2144)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.parseQueryParams(ServletRequestImpl.java:2024)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.getQueryParams(ServletRequestImpl.java:1918)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.getParameter(ServletRequestImpl.java:1995)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.access$800(ServletRequestImpl.java:1817)
         at weblogic.servlet.internal.ServletRequestImpl.getParameter(ServletRequestImpl.java:804)
         at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:169)
         at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:43)
         at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:31)
         at org.apache.myfaces.trinidadinternal.context.external.AbstractAttributeMap.get(AbstractAttributeMap.java:73)
         at oracle.adfinternal.controller.state.ControllerState.getRootViewPortFromRequest(ControllerState.java:788)
         at oracle.adfinternal.controller.state.AdfcContext.initialize(AdfcContext.java:185)
         at oracle.adfinternal.controller.state.AdfcContext.initialize(AdfcContext.java:79)
         at oracle.adfinternal.controller.application.AdfcConfigurator.beginRequest(AdfcConfigurator.java:53)
         at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl._startConfiguratorServiceRequest(GlobalConfiguratorImpl.java:562)
         at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl.beginRequest(GlobalConfiguratorImpl.java:212)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:174)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.net.SocketException: Connection reset
         at java.net.SocketInputStream.read(SocketInputStream.java:168)
         at weblogic.servlet.internal.PostInputStream.read(PostInputStream.java:177)
         at weblogic.servlet.internal.ServletInputStreamImpl.read(ServletInputStreamImpl.java:228)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.mergePostParams(ServletRequestImpl.java:2118)
         ... 39 more
    <UIXEditableValue> <_isBeanValidationAvailable> A Bean Validation provider is not present, therefore bean validation is disabled

    I dont believe that solution pertains to my case. clicked() is invoked from standard jsf page and the adf controller is not acquired yet. i put a couple of print statements in the filter and it seems that the doFilter is called twice! This is not the case when running in 10g.
                if (uri.endsWith(redirect) || mySessionAttribute != null) {
                    System.out.println("URI dofilter: "+uri);
                    filterChain.doFilter(servletRequest, servletResponse);
                } else {
                    System.out.println("URI sendRedirect: "+uri);
                    httpResponse.sendRedirect(redirect);              
                }11g weblogic console log:
    URI sendRedirect: /11gFilterExample-ViewController-context-root/faces/page2
    URI dofilter: /11gFilterExample-ViewController-context-root/faces/page1.jsf
    URI dofilter: /11gFilterExample-ViewController-context-root/faces/page1.jsf
    10g oc4j console log:
    13/01/07 15:48:13 URI sendRedirect: /10gFilterExample-ViewController-context-root/faces/page2.jsp
    13/01/07 15:48:13 URI dofilter: /10gFilterExample-ViewController-context-root/faces/page1.jsp
    I believe whatever thats causing this occur could be why the exception is thrown...

  • Strange behavior when using servlet filter with simple index.htm

    I am new to J2EE development so please tolerate my ignorance. I have a web application that starts with a simple index.htm file. I am using a servlet filter throughout the website to check for session timeout, redirecting the user to a session expiration page if the session has timed out. When I do something as simple as loading the index.htm page in the browser, the .css file and one image file that are associated, or referenced in the file are somehow corrupted and not being rendered. How do I get the filter to ignore css and image files??? Thank you!!
    The servlet filter:
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SessionTimeoutFilter implements Filter {
         String[] excludedPages = {"SessionExpired.jsp","index.htm","index.jsp"};
         String timeoutPage = "SessionExpired.jsp";
         public void destroy() {
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
              if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
                   HttpServletRequest httpServletRequest = (HttpServletRequest) request;
                   HttpServletResponse httpServletResponse = (HttpServletResponse) response;
                   //httpServletResponse.setHeader("Cache-Control","no-cache");
                   //httpServletResponse.setHeader("Pragma","no-cache");
                   //httpServletResponse.setDateHeader ("Expires", 0);
                   String requestPath = httpServletRequest.getRequestURI();
                   boolean sessionInvalid = httpServletRequest.getSession().getAttribute("loginFlag") != "loggedIn";               
                   System.out.println(sessionInvalid);
                   boolean requestExcluded = false;
                   System.out.println(requestExcluded);
                   for (int i=0;i<excludedPages.length;i++){
                        if(requestPath.contains(excludedPages)){
                             requestExcluded = true;
                   if (sessionInvalid && !requestExcluded){
                        System.out.println("redirecting");
                        httpServletResponse.sendRedirect(timeoutPage);
              // pass the request along the filter chain
              chain.doFilter(request, response);
         public void init(FilterConfig arg0) throws ServletException {
              //System.out.println(arg0.getInitParameter("test-param"));
    The index.htm file (or the relevant portion)<HTML>
    <Head>
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="RTEStyleSheet.css" rel="stylesheet" type="text/css">
    <TITLE>Login</TITLE>
    </HEAD>
    <BODY>
    <FORM NAME="Login" METHOD="POST" ACTION="rte.ServletLDAP"><!-- Branding information -->
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
         <tr>
              <td width="30%" align="left"><img src="images/top_logo_new2.gif">
              </td>
              <td width="37%" align="center"></td>
              <td width="33%" align="right"></td>
         </tr>
    </table>
    My web.xml entry for the filter:     <filter>
              <description>
              Checks for a session timeout on each user request, redirects to logout if the session has expired.</description>
              <display-name>
              SessionTimeoutFilter</display-name>
              <filter-name>SessionTimeoutFilter</filter-name>
              <filter-class>SessionTimeoutFilter</filter-class>
              <init-param>
                   <param-name>test-param</param-name>
                   <param-value>this is a test parameter</param-value>
              </init-param>
         </filter>
         <filter-mapping>
              <filter-name>SessionTimeoutFilter</filter-name>
              <url-pattern>/*</url-pattern>
              <dispatcher>REQUEST</dispatcher>
              <dispatcher>FORWARD</dispatcher>
         </filter-mapping>

    Hi,
    Try adding CSS files and images to the excluded Pages.

  • Set Roles in servlet filter

    How can I set the user's role in the request object in a servlet filter
    so that in my action class, i can query the role using
    request.isUserInRole() and request.getUserPrinciple() methods.
    Any ideas...
    Thanks,

    How can I set the user's role in the request object
    in a servlet filter
    so that in my action class, i can query the role
    using
    request.isUserInRole() and request.getUserPrinciple()
    methods.You may want to check out JAAS in the Creator tutorial:
    http://developers.sun.com/prodtech/javatools/jscreator/ea/jsc2/reference/sampleapps/

  • Error Packaging Media!! HTTP request error

    Hi,
    I have followed all the steps given in FAXs_2_0_Quickstart.pdf.
    In Flash Access Manager, I have selected Single file from the local machine with ad-policy.pol,
    when I click Package Media, I am getting the following error message
    FAULT!
    Error Packaging Media!! HTTP request error
    Tomcat log file is showing following error
    org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet UICommunicator threw exception
    java.lang.NumberFormatException: For input string: ""
        at java.lang.NumberFormatException.forInputString(Unknown Source)
        at java.lang.Integer.parseInt(Unknown Source)
        at java.lang.Integer.valueOf(Unknown Source)
        at java.lang.Integer.decode(Unknown Source)
        at com.adobe.flashaccess.refimpl.util.ParamsReader.readPackagerParams(ParamsReader.java:812)
        at com.adobe.flashaccess.refimpl.userinterface.UICommunicator.packageSingleMediaFile(UICommu nicator.java:1438)
        at com.adobe.flashaccess.refimpl.userinterface.UICommunicator.doPost(UICommunicator.java:129 )
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.ja va:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)
    Thanks for the help.

    Hi Eric,
    Pls find below snapshots of the Preferences, Package Media Tabs and error messages.  Other Tabs have been untouched.
    Thanks.

  • How to determine the Servlet which current request is mapped to

    Hello folks,
    having a filter, i want to discover the servlet (if any) which will serve the current request. I want to have it before the chain execution. Does someone has an idea how to accomplish this using Servlet API? The old API provided the getServlet(String name) method for this task. Here the sample code:
    Servlet servingInstance = discoverServlerForRequest(request); //i look for implementation of this method
    chain.doFilter(request,response);I know that it would be very easy to get the servlet AFTER processing the chain, but the clue for me is to get it before.
    Maybe Tomcat has implemented some special servlet context attributes to map it?
    any hint appreciated!
    thanks

    its possible, for sure. but then I need two filters to achieve it. I'll post my solution later, if there wont be any other ideas. I know that tomcat maps many objects by attributes...maybe there is a key for it.

  • Servlet filter problem

    I've written a simple servlet filter to intercept a request to another servlet. So when the user tries to access /servlet/ViewMetadata servlet, they first hit InterceptServlet, the filter configured in Tomcat.
    I need to access the name and URL of the target servlet ViewMetada within InterceptServlet but don't know how to do this. I am familiar with HttpServletRequest.getServletPath() but doFilter uses ServletRequest as its argument.
    Can I obtain the target servlet name inside the filter servlet? I know this is probably very basic!
    Arc

    If the filter is invoked by a HttpServletRequest, then the ServletRequest handle you've in the filter is just an instance of HttpServletRequest.
    Cast it back.

Maybe you are looking for