Regular Expression Filter Mapping In Web.xml

I have a situation where I need to filter URL's that don't have a file extension. There are hundreds of URL's, so i can't specify each one separately.
From what I understand, you can have a filter mapping in web.xml to map certain file extensions to a filter, such as :
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>com.filters.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>*.esi</url-pattern>
</filter-mapping>
...where all files of extension .esi go through the filter. Additionally, I want to map all url's WITHOUT a file extension to pass through this filter. So if I have a request for "http://myserver.com/home" it will pass through the filter.
Does weblogic support regular expressions for pattern matching in filter-mapping? If so, can you provide examples or links to documentation?
Thanks,
Jim

No, regular expressions are not supported. You can specify the mapping with extensions, or with paths, not at the same time in the same mapping specification. However, you can specify two servlet mappings, one with extension, and one with path.
The exact wording from the spec (2.4) is as follows:
In the Web application deployment descriptor, the following syntax is used to define
mappings:
• A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used
for path mapping.
• A string beginning with a ‘*.’ prefix is used as an extension mapping.
• A string containing only the ’/’ character indicates the "default" servlet of
the application. In this case the servlet path is the request URI minus the context
path and the path info is null.
• All other strings are used for exact matches only.

Similar Messages

  • What is Wrong with my filter and filter-mapping in web.xml?

    First, thanks all for your attention.
    I have checked the place where I should place <filter> and <filter-mapping> in web.xm. They should be after the <display-name>, before <servlet> and <servlet-mapping>.
    However, as soon as I insert the <filter> and <filter-mapping> elements in my web.xml, all my struts-bean.tld, struts-html.tld, etc. in the web.xml cannot be found at the runtime.
    Please help in identifying the problem. Thank you.
      <filter>
       <filter-name>trailFilter</filter-name>
       <filter-class>org.osjava.taglib.trail.OriginalRequestFilter</filter-class>
      </filter>
      <filter-mapping>
       <filter-name>trailFilter</filter-name>
       <url-pattern>*.do</url-pattern>
      </filter-mapping>and my web-xml is:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
      <display-name>Struts Example Application</display-name>
      <!-- Action Servlet Configuration -->
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml, /WEB-INF/struts-config-registration.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <!-- Action Servlet Mapping -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
      <!-- The Welcome File List -->
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <!-- The default error page -->
      <error-page>
       <exception-type>java.lang.Exception</exception-type>
       <location>\Error.jsp</location>
      </error-page>
      <!-- Application Tag Library Descriptor -->
      <taglib>
        <taglib-uri>/tags/app</taglib-uri>
        <taglib-location>/WEB-INF/app.tld</taglib-location>
      </taglib>
      <!-- Struts Tag Library Descriptors -->
      <taglib>
        <taglib-uri>/tags/struts-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-nested</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
      </taglib>
    </web-app>

    Filters were introduced in the servlet 2.3 specification (j2ee 1.3) - http://java.sun.com/products/servlet/Filters.html.
    Your web.xml constraints your web application to adhere to 2.2 standards (according to your DOCTYPE definition in your web.xml). Change it to conform to 2.3 standards
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
            //your definitions
    </web-app>Note : Your container should support the 2.3 spec (Tomcat 4.0 and above does, I guess)
    ram.

  • Servlet Filters not following filter mapping in web.xml

    Hi Experts,
    I have two Servlet filters SetCharacterEncodingFilter and LASBackOfficeAuthFilter which are mapped in such a way that SetCharacterEncodingFilter gets called before LASBackOfficeAuthFilter(This is done in web.xml using filter mapping).
    I have code in SetCharacterEncodingFilter init() method to read and store the few parameters from a table , it also creates a new thread to montior db changes in these paremeters . LASBackOfficeAuthFilter reads a those parameters set after SetCharacterEncodingFilter initialization. This is failing in Weblogic Version: 10.3.2.0 because the LASBackOfficeAuthFilter init method gets called before SetCharacterEncodingFilter init method.
    This is filter mapping order is working fine In Web Sphere and Tomcat 6 .
    The web.xml filter mapping is given below .
         <filter>
              <filter-name>LASBackOfficeAuthFilter</filter-name>
              <display-name>Scheduler Authentication Filter</display-name>
              <filter-class>com.scheduler.servlet.backoffice.LASBackOfficeAuthFilter</filter-class>
              <!-- parameters specifying BackOffice servlet path translation -->
              <init-param>
                   <param-name>PathLogin</param-name>
                   <param-value>/login</param-value>
              </init-param>
              <init-param>
                   <param-name>PathLogout</param-name>
                   <param-value>/logout</param-value>
              </init-param>
              <init-param>
                   <param-name>PathNotifications</param-name>
                   <param-value>/secure/notifications</param-value>
              </init-param>
              <init-param>
                   <param-name>PathSchedulerActions</param-name>
                   <param-value>/secure/schedactions</param-value>
              </init-param>
              <init-param>
                   <param-name>PathPing</param-name>
                   <param-value>/secure/ping</param-value>
              </init-param>
         </filter>
         <!--
              this filter sets character encoding and mimetype for requests and
              responses
         -->
         <filter>
              <filter-name>SetCharacterEncodingFilter</filter-name>
              <display-name>Scheduler Character Encoding Filter</display-name>
              <filter-class>com.scheduler.servlet.backoffice.SetCharacterEncodingFilter</filter-class>
         </filter>
         <!-- correlate servlets and filters -->
         <filter-mapping>
              <filter-name>SetCharacterEncodingFilter</filter-name>
              <servlet-name>LASBackOfficeServlet</servlet-name>
         </filter-mapping>
         <filter-mapping>
              <filter-name>LASBackOfficeAuthFilter</filter-name>
              <servlet-name>LASBackOfficeServlet</servlet-name>
         </filter-mapping>
    Any help on this would be very much appreciated .
    Regards
    Dinesh

    No, regular expressions are not supported. You can specify the mapping with extensions, or with paths, not at the same time in the same mapping specification. However, you can specify two servlet mappings, one with extension, and one with path.
    The exact wording from the spec (2.4) is as follows:
    In the Web application deployment descriptor, the following syntax is used to define
    mappings:
    • A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used
    for path mapping.
    • A string beginning with a ‘*.’ prefix is used as an extension mapping.
    • A string containing only the ’/’ character indicates the "default" servlet of
    the application. In this case the servlet path is the request URI minus the context
    path and the path info is null.
    • All other strings are used for exact matches only.

  • FORMAUTH Filter in orion-web.xml ignored

    I am trying to use a JAAS Custom Login Module with a customized logon.jsp (and Struts). So I defined a FORMAUTH Filter in orion-web.xml to intercept the logon.
    However, Oracle 10g 10.1.3.2 did not deploy it. Why? How can I fix this problem?
    ===========================================================
    Deployed Application:
    {ORACLE_10_1_3_2_HOME}\j2ee\home\application-deployments\{APPLICATION}\{APPLICATION_WAR}\orion-web.xml contained:
    <?xml version="1.0"?>
    <orion-web-app
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-web-10_0.xsd"
         deployment-version="10.1.3.1.0"
         deployment-time="1189531757046"
         development="true"
         jsp-cache-directory="./persistence"
         jsp-cache-tlds="standard"
         simple-jsp-mapping="false"
         temporary-directory="./temp"
         servlet-webdir="/servlet"
         context-root="visit"
    schema-major-version="10" schema-minor-version="0" >
         <web-app-class-loader search-local-classes-first="true" include-war-manifest-class-path="true" />
         <web-app>
         </web-app>
    </orion-web-app>
    ===========================================================
    BUT: APPLICATION.EAR structure:
    APPLICATION_WAR\WEB-INF\orion-web.xml contained:
    <?xml version="1.0"?>
    <!DOCTYPE orion-web-app PUBLIC "-//ORACLE//DTD OC4J Web Application 9.04//EN" "http://xmlns.oracle.com/ias/dtds/orion-web-9_04.dtd">
    <orion-web-app
         deployment-version="10.1.3.1.0"
         temporary-directory="./temp"
         internationalize-resources="false"
         default-mime-type="application/octet-stream"
         jsp-cache-directory="./persistence"
         servlet-webdir="/servlet"
         development="true">
              <web-app-class-loader search-local-classes-first="true" include-war-manifest-class-path="true" />
    <web-app>
    <filter>
    <filter-name>AuthenicationFilter</filter-name>
    <filter-class>gov.dhs.visit.filter.AuthenicationFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>AuthenicationFilter</filter-name>
    <dispatcher>FORMAUTH</dispatcher>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>
    </web-app>
    </orion-web-app>

    I've used this before, and it worked fine. The only difference I can see is that you have a url-pattern element in the filter-mapping config.
    In the short term, try removing that and see if it then works.
    -steve-

  • Mime mapping in web.xml not working for csv/excel

    I am using the weblogic 8.1 app server. I want to serve up some static content
    from an "exploded" web application (dir structure instead of a war file). This
    static content includes html files and csv files that cause the browser to give
    an option to the user to open the file in excel or download to disk. I have inserted
    the following mapping inside web.xml in the exploded directory structure...
    <web-app>
    <mime-mapping>
    <extension>csv</extension>
    <mime-type>application/vnd.ms-excel</mime-type>
    </mime-mapping>
    </web-app>
    I redeployed the "web application". When I try to access a csv file, instead of
    giving me the save/open dialog, the browser displays the ASCII contents of the
    csv in the browser like an HTML file. Am I missing a step? Is the xml above not
    for the functionality that I am trying to implement here?
    Thanks.

    Hi All:
    Thanks for all your help regarding the adfAuthentication success_url. Now I am able to configure to make this work. But now I am facing another issue i.e. I am getting 401 Not authorized message when the success_url is pointed to the jspx page.
    Note: I am using custom login module similar to DBProcOraDataSourceLoginModule so my roles are stored in the custom Role class. So I am not sure how to pass this role info to the security in ADF in order to authorize the page to be viewed.
    Could you please help and can you point me to any specific link.
    Thanks & Regards
    Sridhar Doki

  • Order of servlet mapping in web.xml

    Hello,
    is the order of multiple <servlet-mapping> in web.xml important? Or it doesn't matter in which order they are declared?
    For example, if i have two controllers, one is
    <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>
    and the second:
      <servlet>
        <servlet-name>FrontController</servlet-name>
        <servlet-class>servlets.FrontController</servlet-class>
      </servlet>
    and the mapping are:
       <servlet-mapping>
        <servlet-name>FrontController</servlet-name>
        <url-pattern>/jsf/*</url-pattern>
      </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
      </servlet-mapping>where /jsf/ contains jsp pages containing jsf components.
    is the order important?
    And may second question is:
    if i call the jsp page test.jsf in /jsf/test.jsp , which controller is responseble? Faces servlet or Frontcontroller?

    Here is what the 2.4 specification says on the matter (section SRV.11.1):
    >
    The path used for mapping to a servlet is the request URL from the request
    object minus the context path and the path parameters. The URL path mapping rules below are used in order. The first successful match is used with no further matches attempted:
    1. The container will try to find an exact match of the path of the request to the
    path of the servlet. A successful match selects the servlet.
    2. The container will recursively try to match the longest path-prefix. This is done by stepping down the path tree a directory at a time, using the �/� character as a path separator. The longest match determines the servlet selected.
    3. If the last segment in the URL path contains an extension (e.g. .jsp), the servlet container will try to match a servlet that handles requests for the extension. An extension is defined as the part of the last segment after the last �.� character.
    4. If neither of the previous three rules result in a servlet match, the container will attempt to serve content appropriate for the resource requested. If a "default" servlet is defined for the application, it will be used.
    The container must use case-sensitive string comparisons for matching.
    It also notes that in prior versions of the specification these were only a suggestion so if you are on servlet 2.3 or prior, you need to consult the documentation for your container.
    So, to answer your questions, no, order in the descriptor is not important.
    Also, based on the rules above, using your mappings, any URL starting with /jsf will be handled by FrontController including /jsf/test.jsp and /jsf/test.jsf.

  • Agent filter location in web.xml for websphere v7.0

    In the document:
    Sun OpenSSO Enterprise Policy Agent 3.0 Guide for IBM WebSphere Application Server 6.1/7.0 and WebSphere Portal Server 6.1
    I'm and tying to do this part:
    Installing the Agent Filter for the WebSphere Application Server 6.1/7.0 Administration Console
    for my WebSphere 7.0 installation.
    My issue is the placement of the second filter.
    <filter-mapping>
    <filter-name>Agent</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    the doc says to put it under:
    <filter-mapping>
    <filter-name>WSCUrlFilter</filter-name>
    <servlet-name>action</servlet-name>
    </filter-mapping>
    <filter-mapping>
         <filter-name>WSCUrlFilter</filter-name>
    <url-pattern>/federatedlogoff</url-pattern>
    </filter-mapping>
    however, my Websphere 7.0 web.xml does not have this section in the file.
    Can some one assist me with proper placement?
    here is the first few lines of my xml:
    <?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_1" version="2.4" xsi:schemaLocation="http://java.sun.co
    m/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>isclite</display-name>
    <filter>
    <filter-name>WSCUrlFilter</filter-name>
    <filter-class>com.ibm.ws.console.core.servlet.WSCUrlFilter</filter-class>
    </filter>
    <filter>
    <filter-name>Trace_Tree_Cache_Init_Filter</filter-name>
    <filter-class>com.ibm.ws.console.probdetermination.trace.tree.TraceTreeCacheInit</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>WSCUrlFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>Trace_Tree_Cache_Init_Filter</filter-name>
    <servlet-name>Trace Tree Servlet</servlet-name>
    </filter-mapping>
    <listener>
    <listener-class>com.ibm.isclite.SessionListener</listener-class>
    </listener>
    <listener>
    <listener-class>com.ibm.ws.console.appmanagement.SessionListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/config/struts-config.xml</param-value>
    </init-param>
    </servlet>
    <servlet>
    <servlet-name>SecureCleanup</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.SecureCleanupServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>FederationServlet</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.FederationServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>ProfileSelectionServlet</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.ProfileSelectionServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>ConsoleCSS</servlet-name>
    <jsp-file>secure/layouts/console_css.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>EventInitializer</servlet-name>
    <servlet-class>com.ibm.ws.console.events.EventListenerServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>downloadFile</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.DownloadFileServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>StatusServlet</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.StatusServlet</servlet-class>
    </servlet>
    <servlet>

    See below. You just have additional probe filters.
    862059 wrote:
    In the document:
    Sun OpenSSO Enterprise Policy Agent 3.0 Guide for IBM WebSphere Application Server 6.1/7.0 and WebSphere Portal Server 6.1
    I'm and tying to do this part:
    Installing the Agent Filter for the WebSphere Application Server 6.1/7.0 Administration Console
    for my WebSphere 7.0 installation.
    My issue is the placement of the second filter.
    <filter-mapping>
    <filter-name>Agent</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    the doc says to put it under:
    <filter-mapping>
    <filter-name>WSCUrlFilter</filter-name>
    <servlet-name>action</servlet-name>
    </filter-mapping>
    <filter-mapping>
         <filter-name>WSCUrlFilter</filter-name>
    <url-pattern>/federatedlogoff</url-pattern>
    </filter-mapping>
    however, my Websphere 7.0 web.xml does not have this section in the file.
    Can some one assist me with proper placement?
    here is the first few lines of my xml:
    <?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="WebApp_1" version="2.4" xsi:schemaLocation="http://java.sun.co
    m/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>isclite</display-name>
    <filter>
    <filter-name>WSCUrlFilter</filter-name>
    <filter-class>com.ibm.ws.console.core.servlet.WSCUrlFilter</filter-class>
    </filter>
    <filter>
    <filter-name>Trace_Tree_Cache_Init_Filter</filter-name>
    <filter-class>com.ibm.ws.console.probdetermination.trace.tree.TraceTreeCacheInit</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>WSCUrlFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>Trace_Tree_Cache_Init_Filter</filter-name>
    <servlet-name>Trace Tree Servlet</servlet-name>
    </filter-mapping><filter-mapping>
    <filter-name>Agent</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
    <listener-class>com.ibm.isclite.SessionListener</listener-class>
    </listener>
    <listener>
    <listener-class>com.ibm.ws.console.appmanagement.SessionListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/config/struts-config.xml</param-value>
    </init-param>
    </servlet>
    <servlet>
    <servlet-name>SecureCleanup</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.SecureCleanupServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>FederationServlet</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.FederationServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>ProfileSelectionServlet</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.ProfileSelectionServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>ConsoleCSS</servlet-name>
    <jsp-file>secure/layouts/console_css.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>EventInitializer</servlet-name>
    <servlet-class>com.ibm.ws.console.events.EventListenerServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet>
    <servlet-name>downloadFile</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.DownloadFileServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>StatusServlet</servlet-name>
    <servlet-class>com.ibm.ws.console.core.servlet.StatusServlet</servlet-class>
    </servlet>
    <servlet>

  • Sevlet without specific mapping in web.xml

    Hi,
              1. How to invoke a servlet without specfic mapping entry in the web.xml file, by compiling and placing the class file under WEB-INF/classes directory?
              2. Is it correct to mapping the servlets in the directory structure alone (not specific), Like
              <servlet-mapping>
              <servlet-name>/myservlets/*</servlet-name>
              <url-pattern>servlets/../myservlets/*</url-pattern>
              Where * - for servlets under myservlets package compiled and placed under WEB-INF classes and invoked from the browser as
              http://localhost:9999/servlets/../myservlets/testpackage.test
              

    You can use servletservlet :
              web.xml:
              <web-app>
              <servlet>
              <servlet-name>ServletServlet</servlet-name>
              <servlet-class>weblogic.servlet.ServletServlet</servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name>ServletServlet</servlet-name>
              <url-pattern>/servlets/*</url-pattern>
              </servlet-mapping>
              </web-app>
              and your servlet will be accessible as
              http://localhost:7001/yourWebApp/servlets/testpackage/test
              Chitrapandian <[email protected]> wrote:
              > Hi,
              > 1. How to invoke a servlet without specfic mapping entry in the web.xml file, by compiling and placing the class file under WEB-INF/classes directory?
              > 2. Is it correct to mapping the servlets in the directory structure alone (not specific), Like
              > <servlet-mapping>
              > <servlet-name>/myservlets/*</servlet-name>
              > <url-pattern>servlets/../myservlets/*</url-pattern>
              >
              > Where * - for servlets under myservlets package compiled and placed under WEB-INF classes and invoked from the browser as
              > http://localhost:9999/servlets/../myservlets/testpackage.test
              Dimitri
              

  • Regular expression to extract value from xml

    Hi,
    I need to extract the value of an XML tag.
    <purchaseId>Best-200423</purchaseId>
    The result of the expression should be: "Best-200423".
    Something like this ([^\\<purchaseId\\>]*[^\\</purchaseId\\>]) does not work.
    Does somebody has a soltuion?
    I can't get it to work! I want to use the Java Regular Expression functionality.
    Best wishes
    Jochen

    You got lucky, is all. Try changing "Best" to "pest" in your example and it won't work. The square brackets are spurious, and you want m.getGroup(1) to get the stuff that matches the () group.
    Square brackes mean "match any of the characters in the brackets". [^ means "match any character not in this list").                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • JSP Servlet Mapping  in web.xml

    Hi!
    I have a JSP page by name "ContactUs.jsp" located in the folder <root>/jsp/info and I am using Tomcat Server. As I want to access this file using the URL "http://localhost:8080/<webapp>/ContactUs.jsp" instead of "http://localhost:8080/<webapp>/jsp/info/ContactUs.jsp". For this I added the follwing lines to web.xml file of my web app.
    <servlet>
    <servlet-name>org.apache.jsp.jsp.info.ContactUs_jsp</servlet-name>
    <servlet-class>org.apache.jsp.jsp.info.ContactUs_jsp</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>org.apache.jsp.jsp.info.ContactUs_jsp</servlet-name>
    <url-pattern>/ContactUs.jsp</url-pattern>
    </servlet-mapping>
    But I am getting the error saying that
    "ClassNotFoundException: org.apache.jsp.jsp.info.ContactUs_jsp"
    Is there any thing else to be modified? Please help me.
    Thanks in advance
    Geethanadh.K

    I'm no expert on this but I have a hunch. 1st of all, your using a servlet mapping for a JSP. That's good and well but it seems that the container is complaining that there is no servlet named org.apache.jsp.jsp.info.ContactUs_jsp. In other words it looks like the JSP has not been compiled. At least not yet. Maybe try two things. Visit the JSP once with a browser at it's actual path "http://localhost:8080/<webapp>/jsp/info/ContactUs.jsp" the coerce a page compile. Then try it with your new mapped path. You see, just telling the container that there is a servlet mapped to the new URL doesn't force the container to generate the class. Something or someone must generate the servlet class file.
    Honestly, I'm not sure of what your end goal is but maybe you might consider using a JSP pre-compiler? Or even better, register a servlet at the mapped path that fowards all requests into the desired folder.
    Cliff

  • What is Wrong with filter and filter-mapping in My web.xml?

    First, thanks all for your attention.
    I have checked the place where I should place <filter> and <filter-mapping> in web.xm. They should be after the <display-name>, before <servlet> and <servlet-mapping>.
    However, as soon as I insert the <filter> and <filter-mapping> elements in my web.xml, all my struts-bean.tld, struts-html.tld, etc. in the web.xml cannot be found at the runtime.
    Please help in identifying the problem. Thank you.
      <filter>
       <filter-name>trailFilter</filter-name>
       <filter-class>org.osjava.taglib.trail.OriginalRequestFilter</filter-class>
      </filter>
      <filter-mapping>
       <filter-name>trailFilter</filter-name>
       <url-pattern>*.do</url-pattern>
      </filter-mapping>and my web-xml is:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
      "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
      <display-name>Struts Example Application</display-name>
      <!-- Action Servlet Configuration -->
      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml, /WEB-INF/struts-config-registration.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>
      <!-- Action Servlet Mapping -->
      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
      <!-- The Welcome File List -->
      <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <!-- The default error page -->
      <error-page>
       <exception-type>java.lang.Exception</exception-type>
       <location>\Error.jsp</location>
      </error-page>
      <!-- Application Tag Library Descriptor -->
      <taglib>
        <taglib-uri>/tags/app</taglib-uri>
        <taglib-location>/WEB-INF/app.tld</taglib-location>
      </taglib>
      <!-- Struts Tag Library Descriptors -->
      <taglib>
        <taglib-uri>/tags/struts-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
      </taglib>
      <taglib>
        <taglib-uri>/tags/struts-nested</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
      </taglib>
    </web-app>

    Multiple Post - http://forum.java.sun.com/thread.jspa?threadID=734506

  • Is it possible to add a filter to a webapp without declaring it in web.xml

    Hello,
    I'd like to add a filter in my web.xml file, but without declaring it in my webapp.
    Indeed, I have multiple webapps, and I'd like to have a common web.xml file that should be directly included in all the webapps including this package ?
    Is it possible or not ?
    As for JSF, it is possible to add faces-config file by putting it in the META-INF of the package.
    Thanks in advance.
    bgOnline

    Your title and your question are opposites...
    A filter must be specified in a web.xml to be used. That doesn't mean the Filter's class HAS to be in your webapp, it just must be accessible to the Servlet container (you could place it in the common/classes directory or shared/classes directory or even the server/classes directory).
    I've not tried it, but I see no reason why you couldn't declare the filter and filter-mapping in the server's web.xml which would then filter all requests in all webapps.
    HTH.

  • URL Mapping for packaged JSP's in web.xml file

              Hi,
              I am using weblogic6.0sp2 enterprise edition.I have my JSP's in package structure.
              Suppose my login.jsp is in package com.advice.document. So for URL mapping in
              web.xml what should be given so that by giving that my JSP runs. I have tried
              many options but not got success.
              Here is my web.xml file..
              <web-app>
              <servlet>
              <servlet-name> Login </servlet-name>
              <jsp-file> com\advice\document\login.jsp</jsp-file>
              </servlet>
              <servlet-mapping>
              <servlet-name> Login </servlet-name>
              <url-pattern> /Login</url-pattern>
              </servlet-mapping>
              </web-app>
              If any body knows or have worked on the same then let me know.
              Thanks in advance.
              --- Vipul
              

    Did you try specifying the jsp-file with forward slashes (e.g.,
              com/advice/document/login.jsp)?
              Vipul Garg wrote:
              > Hi,
              > I am using weblogic6.0sp2 enterprise edition.I have my JSP's in package structure.
              > Suppose my login.jsp is in package com.advice.document. So for URL mapping in
              > web.xml what should be given so that by giving that my JSP runs. I have tried
              > many options but not got success.
              > Here is my web.xml file..
              > <web-app>
              > <servlet>
              > <servlet-name> Login </servlet-name>
              > <jsp-file> com\advice\document\login.jsp</jsp-file>
              > </servlet>
              > <servlet-mapping>
              > <servlet-name> Login </servlet-name>
              > <url-pattern> /Login</url-pattern>
              > </servlet-mapping>
              > </web-app>
              >
              > If any body knows or have worked on the same then let me know.
              > Thanks in advance.
              > --- Vipul
              

  • Do we need to put the following code in the web-xml for the project to run

    Hi^^^,
    actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
    I know 404 error is generally due to some error in deployment descriptor.
    I am going through this tutorial for creating project in eclipse WTP
    this says that I need to include the following code in web-xml. Please look at the quotes below
    "Web modules in J2EE has a deployment descriptor where you configure the web application and its components. This deployment descriptors is called the web.xml. According to the J2EE specification, it must be located in the WEB-INF folder. web.xml must have definitions for the Servlet and the Servlet URI mapping. Enter the following lines into web.xml:"
    "Listing 2. Deployment Descriptor web.xml"
    <servlet>
    <servlet-name>Snoop Servlet</servlet-name>
    <servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Snoop Servlet</servlet-name>
    <url-pattern>/snoop/*</url-pattern>
    </servlet-mapping>
    My question is, it is necessary to include the above lines between <servlet> and </servlet-mapping> in web-xml
    thanks and regards,
    Prashant

    pksingh79 wrote:
    actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
    I know 404 error is generally due to some error in deployment descriptor. what's the url you've put.
    <servlet>
    <servlet-name>Snoop Servlet</servlet-name>
    <servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
    </servlet> Every Servlet has to have a <servlet></Servlet> tag in the web.xml
    the <servlet-name>is for the naming the servlet and the <servlet-calss>is for class file of the servlet in your case the .class file is to be in the package of tutorial,if it's not then how the container will no where the calss file is
    <servlet-mapping>
    <servlet-name>Snoop Servlet</servlet-name>
    <url-pattern>/snoop/*</url-pattern>
    </servlet-mapping>You type something in your url likk http://localhost:8080/webappname (Tomcat server),so for url mapping instead of typing the entire class file name ,you just enough have to type what you've put in the <url-mapping> tag and it has to be inside of <servlet-mapping>
    I think the problem is in <url-pattern> change it like /snoop<url-pattern>
    My question is, it is necessary to include the above lines between <servlet> and ></servlet->mapping> in web.xmlSo now you think whether you need something inside <servlet>and </servlet-mapping>

  • Question about web.xml

    So in my web.xml file (for Tomcat 5.5) I used to map a servlet like this:
    <servlet-mapping>
    <servlet-name>
    ServletName
    </servlet-name>
    <url-pattern>
    /servlet/ServletName
    </url-pattern>
    </servlet-mapping>and it wouldn't work. Now when I map it like this:
    <servlet-mapping>
    <servlet-name>
    ServletName
    </servlet-name>
    <url-pattern>
    /servlet/*
    </url-pattern>
    </servlet-mapping>it works just fine. Can anyone explain to me why this is since I've seen web.xml files that don't use the /* for the dir. location?
    Thanks in advance.

    I posted this too soon. Using that 'wild card' it grabs the last servlet mapped in web.xml. So I commented everything out and left the file with the following(I used '*' just to keep stuff private):
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
        <display-name>DISPLAY NAME</display-name>
        <description>
         DISPLAY NAME
        </description>
       <servlet>
    <servlet-name>SignIn</servlet-name>
        <servlet-class>lmt.SignIn</servlet-class>
    <init-param>
          <param-name>url</param-name>
          <param-value>jdbc:mysql://localhost/********</param-value>
        </init-param>
        <init-param>
          <param-name>**********</param-name>
          <param-value>*******</param-value>
        </init-param>
        <init-param>
          <param-name>********</param-name>
          <param-value>***********</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>
    SignIn
    </servlet-name>
    <url-pattern>
    /servlet/SignIn
    </url-pattern>
    </servlet-mapping>
    </web-app>This is will not locate the servlet.
    I get a 404 with this message: "type Status report
    message /servlet/SignIn/
    description The requested resource (/servlet/SignIn/) is not available.
    I really have no idea what's wrong here. Is there a problem with some configuration elsewhere? Thanks again.

Maybe you are looking for