Question in spring-web.xml

My application's name is Example.
I want all webpages from /Example/*.htm to be directed to a servlet.
And all pages from /Example/a/code to be directed to another servlet.
"Code" does not end with .htm.
I tried the below mapping in the web.xml. It does not work.
<servlet-mapping>
     <servlet-name>Example</servlet-name>
     <url-pattern>/a/</url-pattern>
     </servlet-mapping>
     <servlet-mapping>
     <servlet-name>Example</servlet-name>
     <url-pattern>*.htm</url-pattern>
     </servlet-mapping>
It works only if I add the following :
     <servlet-mapping>
     <servlet-name>Example</servlet-name>
     <url-pattern>/</url-pattern>
     </servlet-mapping>
I dont want to add the above code. Is there another way. For some reason, spring throws an error with /a/*.

Thanks for the reply.
I did end up doing something like that in the end. I think I just couldn't get my mind into gear as usual on Monday.
What's happening is taking a nice neat human readable URL and converting it to the horrible URL used by the system. The reason it's a filter is because someone had written a tiny filter would might only execute 20 lines of code and I think someone felt it was easier to just lump about 240 more lines to execute on each request, which, even if it isn't a huge strain on the system it's nasty and most of the code is unnecessary the vast majority of the time. I'm splitting it up the whole lot based on the various tasks.
This particular functionality could be a servlet. I probably would have done it that if given the task from scratch but I think sometimes I put too much faith in the fact those with more experience should know better. I think I'll try it as a servlet and if someone has concerns about it then I'll ask them to explain to me why it can't be one.

Similar Messages

  • How many web.xml in a java application

    Hi,
    can anyone give tell the answer for this question "How many web.xml in a java application?"

    1Why ?Because the Web container refers to only one web.xml for one web application.
    I havent heard of an application having more than 1 web.xml
    How?It reads all the definitions of servlet mappings, filters, welcome-file etc from this file itself.
    Where?From the following folder ...
    /WEB-INF
    By the way ..... the way you questioned me was amuzing ... Why? How ?Where ? Its funny :D
    I actually wanted to reply as below ..
    Why ?Why not
    How?
    Wait lemme think ....ummm... What do you mean how??
    Where ?
    Inside the web ;-)
    -Rohit

  • (newbie) Question about replacing .class files and web.xml file

    I'm new to servlets and I have two quick questions...
    Do I absolutely need a web.xml file to define all my servlets, or can I simply place .class files into the WEB-INF directory and expect them to run?
    If my application server (for example Tomcat) is running and I replace a servlet .class file, do I need to restart the server for the new .class file to take effect?
    ...or are both of these questions specific to the application server I'm using?

    Hi,
    From an article I read:
    With Tomcat 3.x, by default servlet container was set up to allow invoking a servet through a common mapping under the /servlet/ directory.
    A servlet could be accessed by simply using an url like this one:
    http://[domain]:[port]/[context]/servlet/[servlet full qualified name].
    The mapping was set inside the web application descriptor (web.xml), located under $TOMCAT_HOME/conf.
    With Tomcat 4.x the Jakarta developers have decided to stop allowing this by default. The <servlet-mapping> tag that sets this mapping up, has been commented inside the default web application descriptor (web.xml), located under $CATALINA_HOME/conf:
    <!-- The mapping for the invoker servlet -->
    <!--
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    -->
    A developer can simply map all the servlet inside the web application descriptor of its own web application (that is highly suggested), or simply uncomment that mapping (that is highly discouraged).
    It is important to notice that the /servlet/ isn't part of Servlet 2.3 specifications so there are no guarantee that the container will support that. So, if the developer decides to uncomment that mapping, the application will loose portabiliy.
    And declangallagher, I will use caution in future :-)

  • XML Question for web.xml file for LiteWebServer

    Hi,
    I have no clue of wut tags are required in the web.xml file.
    Currently the following code is in my web.xml file and i am trying to run servlets that are located under web-inf/*.class
    Pls tell me wuts wrong....
    Do i need those mime-mapping tags, session and welcome tags.......... ?
    Right now i just want those 2 servlets to work
    And wut is this encoding ="UTF-8" in the first line of the xml file. Wut does that do... ? ARe there any others
    Any help would b greatly appreciated
    Thanks
    <?xml version="1.0" encoding="UTF-8" ?>
    <!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 id="WebApp_1">
    <display-name>PDMPortal</display-name>
    <session-config id="SessionConfig_1">
    <session-timeout>60</session-timeout>
    </session-config>
    <mime-mapping id="MimeMapping_1">
    <extension>htc</extension>
    <mime-type>text/x-component</mime-type>
    </mime-mapping>
    <welcome-file-list id="WelcomeFileList_1">
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>HelloWorld</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>HelloWorldExample</servlet-name>
    <servlet-class>HelloWorldExample</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>HelloWorld</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>HelloWorldExample</servlet-name>
    <url-pattern>HelloWorldExample</url-pattern>
    </servlet-mapping>
    </web-app>

    Try putting your servlets in the WEB-INF\classes directory.

  • Web.xml question

    Hi Guys!
    I ran into a small problem.
    Im using the struts tiles framework to redesign a shopping cart .
    In the new framework,there are multiple websites(user interface tiles) that use the same servlets at the back end to process the requests. The control is passed back to the website that called the commonly shared servlets once the computations are done.The servlets, the various websites that use the servlets all reside on the same server and are a part of the same project.
    The whole project shares a common web.xml file.
    I was just wondering if each of the tiles can have thier own web.xml so that the servlet context can be loaded from them.
    The directory structure is like this
    Tiles Framework
    -Servlet Source
    -web.xml
    -tiles (folder)
    ---tile1(folder...contains the 1st website)
    ---tile2
    ---tile 3
    The reason being that in the older version of the shopping cart, the web.xml was used to load specfic contexts in the servlets.
    Is it possible that wach of the tiles has its own web.xml ?
    if so, does it require any configuration in the overall project.
    Thanks.

    If I understand the web.xml file correctly, there should only be one per project. But if it's just a matter of loading props for each of the tiles, can't you just have a different properties file for each tile?
    I can't imagine a situation where you'd be required to have multiple web.xml files within the same project. Can you explain why you can't just have several regular property files & read from them instead?

  • Question on defining taglib in  web.xml

    I am using netbeans to develop a j2ee5 web application.
    I created a web application project using the wizard.
    When I defined a <taglib> in the web.xml, it detected an error.
    cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'. One of '{"http://java.sun.com/xml/ns/javaee":description, "http://java.sun.com/xml/ns/javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/javaee":distributable, "http://java.sun.com/xml/ns/javaee":context-param, "http://java.sun.com/xml/ns/javaee":filter, "http://java.sun.com/xml/ns/javaee":filter-mapping, "http://java.sun.com/xml/ns/javaee":listener, "http://java.sun.com/xml/ns/javaee":servlet, "http://java.sun.com/xml/ns/javaee":servlet-mapping, "http://java.sun.com/xml/ns/javaee":session-config, "http://java.sun.com/xml/ns/javaee":mime-mapping, "http://java.sun.com/xml/ns/javaee":welcome-file-list, "http://java.sun.com/xml/ns/javaee":error-page, "http://java.sun.com/xml/ns/javaee":jsp-config, "http://java.sun.com/xml/ns/javaee":security-constraint, "http://java.sun.com/xml/ns/javaee":login-config, "http://java.sun.com/xml/ns/javaee":security-role, "http://java.sun.com/xml/ns/javaee":env-entry, "http://java.sun.com/xml/ns/javaee":ejb-ref, "http://java.sun.com/xml/ns/javaee":ejb-local-ref, "http://java.sun.com/xml/ns/javaee":service-ref, "http://java.sun.com/xml/ns/javaee":resource-ref, "http://java.sun.com/xml/ns/javaee":resource-env-ref, "http://java.sun.com/xml/ns/javaee":message-destination-ref, "http://java.sun.com/xml/ns/javaee":persistence-context-ref, "http://java.sun.com/xml/ns/javaee":persistence-unit-ref, "http://java.sun.com/xml/ns/javaee":post-construct, "http://java.sun.com/xml/ns/javaee":pre-destroy, "http://java.sun.com/xml/ns/javaee":message-destination, "http://java.sun.com/xml/ns/javaee":locale-encoding-mapping-list}' is expected.
    Here is my web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <welcome-file-list>
    <welcome-file>
    index.jsp
    </welcome-file>
    </welcome-file-list>
    <taglib>
    <taglib-uri>/mytag</taglib-uri>
    <taglib-location>/WEB-INF/mytag.tld</taglib-location>
    </taglib>
    </web-app>

    As of servlet 2.4 (jsp 2.0), you'll have to move the taglib declarations inside a <jsp_config> element.
    <jsp-config>
        <taglib> ..........your stuff
    </jsp-config>ram.

  • ANT Newbie question webxml="web.xml" ????

    I have following lines in my build.xml
    <war
            basedir="../"
            warfile="${distpath.project}/${project.distname}.war"
            webxml="web.xml">
            <exclude name="${distpath.project}/${project.distname}.war"/>
    </war>Can anybody tell me what is the meaning of webxml="web.xml" ???
    Also, if i am not wrong, does the last line mean that exclude the .war file while creating the war ???
    Thanks !!!

    Can anybody tell me what is the meaning of
    webxml="web.xml" ???This attribute is used to specify the XML file which contains the deployment descriptors for the web app. In short, if you specify "mydesc.xml" there, the XML will be copied to WEB-INF/web.xml
    Also, if i am not wrong, does the last line mean that
    exclude the .war file while creating the war ???This might be something like excluding the previously generated WAR files. Not sure really!

  • 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.

  • Question on web.xml in OAF

    Hi Friends,
    when i open web.xml in jdeveloper window, i can able to see my application(instance) user name and pass word.
    what can i do to remove my password in web.xml. is there any set up to do for instead of displaying password name display as some *****************.
    Thanks in advance,
    vamshi.

    Hi Reetesh,
    Thank you.
    atleat can we hide this below part in web.xml..
    <context-param>
    <param-name>OA_LOGIN_PASSWORD</param-name>
    <param-value>krishna12</param-value>
    </context-param>
    Regards,
    vamshi.

  • Web.xml - security constraint question

    I want to make a kind of inverted security constraint. I want to ALLOW access to one specific page over HTTP. All other pages should be HTTPS.
    Is that possible???

    Use the <security-role-ref> for the Faces Servlet to map the LDAP roles to the logical role names used by the managed bean to determine if links may be rendered.
    Bean code:
    this.isAdmin = context.getExternalContext().isUserInRole("admin");web.xml:
            <security-role>
              <role-name>Local Admin Group</role-name>
         </security-role>
         <security-role>
              <role-name>DBA Group</role-name>
         </security-role>
        <!-- Faces Servlet -->
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <security-role-ref>
                  <role-name>admin</role-name>
                  <role-link>DBA Group</role-link>
           </security-role-ref>
            <security-role-ref>
                  <role-name>admin</role-name>
                  <role-link>Local Admin Group</role-link>
           </security-role-ref>
        </servlet>

  • Web.xml servlet redirection question

    Hi everyone;
    As you know web.xml file allows you to enter something like this
         <servlet-mapping>
              <servlet-name>application1</servlet-name>
              <url-pattern>/application1</url-pattern>
         </servlet-mapping>
    so you can find your application.
    As you know it is case sensitive so if a user enters /Application1 it wouldn't be found. I was wondering if i could put a node in there that would redirect requests from Application1 to application.
    Any ideas ?
    Stev

    oh i wasn't aware that i could put multiple nodes in there like this
    <servlet-mapping>
    <servlet-name>application1</servlet-name>
    <url-pattern>/application1</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>application1</servlet-name>
    <url-pattern>/Application1</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>application1</servlet-name>
    <url-pattern>/APplication1</url-pattern>
    </servlet-mapping>
    is there a way to simply make this case insensitive and all requests get translated to the lowercase versioN?
    Stev

  • Simple web.xml question

    Hi all,
    Do I have to restart Tomcat whenever I make changes to any web.xml file(either global or individual web apps)?
    Thanks for your help.

    No.
    You have UpdateFiles and Deploy options in the Deploy Tool Version 8, for example. This is an elegant solution.
    I am sure that there is also a command from the command prompt. But I have already forgoten.

  • Web.xml question -- ejb-ref

    Can anyone explain the reasons for using the <ejb-ref> tag in the web.xml file?
    Currently, I have a context-param that matches a param-name to a param-value. My code looks up the param-value and, via JNDI, gets the EJB referenced.
    Does the <ejb-ref> tag provide an easier, more standard method for doing this or is it there just to show that particular EJB is referenced?
    Any information would be very helpful.

    Thanks, but this makes no sense to me. Why should a
    web app be different than any other app? Why make a
    special tag?
    Is this tag required? Is it possible to use an EJB
    without it or is this someone required?Your webapp can access the ejb without this tag at all but using its jndi name. This tag (<ejb-ref>) is just a standard way of accessing ejb's within the webapp.
    For eg. consider this WEB.XML,
    <ejb-ref>
    <description>Reference to DEPT bean</description>
    <ejb-ref-name>EJB-DeptRecord</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <home>com.test.DeptHome</home>
    <remote>com.test.DeptRemote</remote>
    </ejb-ref>
    You can lookup like this using the ejb-reference name.
    Context ctx = new InitialContext();
    Object obj = ctx.lookup("java:comp/env/EJB-DeptRecord"); <-------
    Since JNDI names usually have directory structure (eg. /test/ejb/..),
    this ejb-ref tag provides a convenient way to do the lookup without the jndi-name cluttering up your code.

  • Question on web.xml and login

    Hi all
    I am doing a web-based project, registered user need to log in before they view the member area pages.
    I have created a directory, called "client", in the Tomcat 4.1.24/webapps/ROOT/client I have put a index.html in the client directory. This index.html only can be viewed by the client after log in.
    For the best of my knowledge in Tomcat, in order to do this, I have created a web.xml in Tomcat_home/webaggs/ROOT/WEB-INF/web.xml, in the url-pattern section, I put /client/* to tell the tomcat server that index.html in client directory is the first page after user login.
    The problem is, I couldnt see the member welcome page after I login as a member, the browser gave me the error: HTTP status 400 - Invalid direct reference to form login page. However, if I specified the address http://localhost:8080/client/index.html , it show me the login page and after I input the username and password I can see the member welcome page.
    I dont know whether is something wrong with the web.xml or I should do other thing to let the server know which is the first page after member login.
    Thank you very much
    Kelvin
    =====================================================
    <web-app>
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Security</web-resource-name>
    <url-pattern>/client/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>administrator</role-name>
         <role-name>client</role-name>
    </auth-constraint>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
    <form-login-page>/login.html</form-login-page>
    <form-error-page>/login_error.html</form-error-page>
    </form-login-config>
    </login-config>
    </web-app>
    =====================================================

    Wow, you really are in the wrong place with this query, its not really even java ;o) This is the new to java forum! Perhaps you would be better off (in fact I know for a FACT that you will be as I have seen answers to identical problems there) in the Tomcat-user list...
    Go HERE:
    http://www.mail-archive.com/[email protected]/
    and search

  • Not able to consume Spring web services form Apex.

    Hi all,
    I have written web services using Spring web services and i have tested them using SoapUi- web services testing tool. But when i try to consume the same using Apex, Apex fails to parse the Wsdl properly and invalid request and response elements are created.
    The request and response elements are in an different xsd and i have imported it in the wsdl.
    Problem: when Apex parses the wsdl, it fails to download the referenced xsd and hence fails to create the request and response elements properly.
    Questions: Can apex download an xsd through http? if yes, how do we enable apex to do it.
    What are the other options available.?
    I have pasted a extract from the wsdl below:
    <?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:schema="http://com/webservice" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://com/webservice">
    <wsdl:types>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"><xsd:import namespace="http://com/webservice" schemaLocation="../model/WebServiceModel.xsd"/></xsd:schema>
    </wsdl:types>
    Regards
    Anish

    Anish:
    Application Express will attempt to download external XSD references (version 3.0 or later), but I believe the problem with this particular reference is that the reference is relative:
    ../model/WebServiceModel.xsd
    Another option is to use the Manual Web references feature. You can use a tool like SOAPUI to get a properly formatted SOAP Envelope for the operation of the particular service you wish to interact with.
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/advnc.htm#BABCBBHJ (Creating a Web Service Manually)
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/web_serv.htm#CHDEFEGH
    Regards,
    Jason

Maybe you are looking for