Web.xml configuration

Hi,
I want to configure web.xml in such a way that all requests will be handled by a single servlet. I don't have anything common for all requests in the url pattern.
<servlet>
     <servlet-name>myServlet</servlet-name>
     <servlet-class>com.app.test.MyServlet</servlet-class>
     <load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
     <servlet-name>myServlet</servlet-name>
     <url-pattern>/*</url-pattern>
</servlet-mapping>
I tried to configure this way, by making url-pattern as /*. But its running into an infinite loop.
I also tried giving the context name in the url-pattern, <url-pattern>/mycontext/*</url-pattern>. Unfortunately this also doesn't work for me.
Solutions/suggestions are welcome. Thank you.
-Prasanna

Using "/" or "/*" will make one servlet as the default, so you're on the right track there. However, keep in mind that a more exact match or a longer match will win in case of conflict.
The infinite loop you talk about is probably because you try to redirect from within your handler servlet and that new request obviously gets intercepted again.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
----------------------------------------------------------------

Similar Messages

  • JSF 1.2 web.xml configuration parameters

    Actually, I know these JSF 1.2 web.xml configuration parameters:
    javax.faces.CONFIG_FILES
    javax.faces.DEFAULT_SUFFIX
    javax.faces.LIFECYCLE_ID
    javax.faces.STATE_SAVING_METHOD
    Are there any more available?
    (I have to study its performance implications in conjunction with RichFaces ones).

    The JSF 1.2 specification document would contain the information you're looking for.

  • JSP include through a web.xml configuration

    I have a website that has many JSP pages and I would like to add some logging lines to each jsp file. I would prefer not to have to edit each jsp file though (it would be time consuming). Is there a way through a configuration change in the webapp web.xml file to make each jsp page first "go through" a servlet (to perform some logic) and then have the servlet pass the request and response on to the jsp file. If so, I could add the logging logic to the servlet and effectively have the logic added to each jsp file.
    If anyone has done something like this, please give me some pointers on how to configure it.
    Thanks,

    It sounds like a servlet filter is what you are after.
    http://java.sun.com/products/servlet/Filters.html
    Its pretty much exactly what you had, just using a Filter interface instead of a servlet.
    Should be something along the lines of this (untested)
    In web.xml:
    <filter>
    <filter-name>jsplogger</servlet-name>
    <filter-class>dagger.servlet.JSPLoggerFilter</servlet-class>
    </filter>
    <filter-mapping>
    <filter-name>jsplogger</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>Filter class:
    public class JSPLoggerFilter implements Filter{
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, ServletException
      String s=request.getRequestURI();
      System.out.println(s+" "+request.getSession().getId());
      // pass it on down the chain
      chain.doFilter(request, response);
    }Cheers,
    evnafets

  • Web.xml  configured correctly(I think),  but still getting '404...resource

    not found error' from tomcat. Here is my web.xml:
    <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloServlet</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>HelloServlet2</servlet-name>
    <servlet-class>coreservlets.HelloServlet2</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/classes/HelloServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>HelloServlet2</servlet-name>
    <url-pattern>/classes/coreservlets.HelloServlet2</url-pattern>
    </servlet-mapping>
    </web-app>
    when I went to the following urls after I had edited web.xml to the above,
    http://localhost:8080/cucoweb/classes/coreservlets.HelloServlet2
    http://localhost:8080/cucoweb/classes/HelloServlet
    I go the expected results, ie, 'Hello(2)' and 'Hello'. Then I shutdown tomcat and restarted it.
    And when i tried to access those 2 urls again, I got the above error.
    (Actually I had the same web.xml before except that it didnt have the /classes in front in the
    url-pattern. I was able to access it by the same url - without the /classes - and then the next day
    when started tomcat and tried to access it, it didnt work, same error.)
    In this example, cucoweb is the context root, correct ? Shouldn't the url-pattern be relative to the
    context root ? Thats how I have it now, I think.
    Would adding my webapp directory, ie cucoweb/classes, to my CLASSPATH help ?
    I'm in ubuntu, when I do echo $CLASSPATH, I get :
    .:/usr/lib/jvm/java-6-sun-1.6.0.00/lib:/usr/lib/jvm/java-6-sun-1.6.0.00/imq/lib/:/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib
    I havent tried this yet because doing this is kind of tricky in ubuntu. (You have etc/environment and
    bash.bashrc, for ex.) But if I try that and it works I will post about it. I suspect its something else,
    though, because it worked once, before restarting tomcat, thats why I'm posting here first.
    Any info, even educated guesses, would be greatly appreciated. Thanks in advance.

    Thanks for the reply. Here is my web structure :
    /usr/local/tomcat/apache-tomcat-6.0.14/webapps/cucoweb/WEB-INF/classes
    From my understanding you are supposed to have your own webapp deployment directory
    under webapps, ie, cucoweb, and not use webapps/ROOT. (I'm not sure what /ROOT is even for)
    My web.xml is in WEB-INF. My /classes directory contains HelloServlet.class and a directory
    called coreservlets which contains HelloServlet2.class.
    I'm not sure what you mean by 'better you to delete under tomcat/work/catalina/localhost folder'.
    Can you please clarify ?
    FYI, my work/catalina/localhost contains the following :
    cucoweb docs examples host-manager manager
    Here cucoweb just contains a SESSIONS.ser file. Are you saying i should delete that ?

  • Web.xml configuration for initial servlet load

    Hi all,
    I have heard of entering some tag into web.xml file (deployement descriptor) if we need some servlets to be loaded wheneve the app server starts or restarts. can some body help me regarding what to write in web.xml.
    thanks in advance

    I am having some problems with the same issue although specifying the load-on-startup param is not working for.
    Here is snipet of the web.xml:
    <servlet id="Servlet_1206024889339">
    <servlet-name>ContentServer</servlet-name>
    <servlet-class>COM.FutureTense.Servlet.SContentServer</servlet-class>
    <init-param id="InitParam_1206024988781">
    <param-name>inipath</param-name>
    <param-value>/data/WebSphere/ContentServer</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    This however doesn't init the contentServer servlet. Is there anythign else i need to check? I am using websphere5-1.
    I saw somewhere you might have to specify a loadonstartup=true? Where is this set?
    I know the app is reading the right web.xml because i put in a bad value and saw the error being outputted in the startup log.
    There are some servlets being initialised on startup but not the ones I want. These servlets don't seem to be in the web.xml.
    [10/10/08 11:53:30:265 IST] 1e06de8 WebContainer A SRVE0169I: Loading Web Module: cs.war.
    [10/10/08 11:53:33:330 IST] 1e06de8 WebGroup I SRVE0180I: [cs.war] [servlet] [Servlet.LOG]: JSP 1.2 Processor: init
    [10/10/08 11:53:34:098 IST] 1e06de8 WebGroup I SRVE0180I: [cs.war] [servlet] [Servlet.LOG]: SimpleFileServlet: init
    [10/10/08 11:53:34:117 IST] 1e06de8 WebGroup I SRVE0180I: [cs.war] [servlet] [Servlet.LOG]: DirectoryBrowsingServlet: init

  • Catch the exception thrown when database is not available in web.xml

    Hi,
    I have an app that uses a mysql database configured in the web.xml configuration file - a javax.servlet.jsp.jstl.sql.dataSource param
    There have been occasions where that server has been down, and this causes the expected error stack trace to be dumped to the jsp page
    Is there anywhere I can catch that exception in the jsp page, so the end user does not see that nasty error?
    Thanks,
    Tom

    You have answered your own question, catch the exception with a try catch block !!
    try
    // doing something stupid
    catch (Exception exception)
    out.println("sorry user, you did something really stupid");
    // it is acceptable to do nothing here if you dont want to handle the
    // error or output a message
    }

  • Is there a web.xml equivalent???

    does the Apache web server included with Oracle 9ias have an equivalent to the web.xml configuration common with applications deployed on Tomcat?
    I am attempting to port a Tomcat application to 9ias but I have been unsuccessful because I am having problems with jars not being found. I checked the demos that come with 9ias and noticed that they don't have a web.xml file. I am thinking this may be one of my problems.
    any insight or pointers to documentation about this would be greatly appreciated.
    I've read a lot of documentation and new group posts but have been unable to find a solution to my problem.
    thank you

    Is this one of the cases that were inscribed on the inside by Jobs, Wozniak, and the rest of the design team?  I could take it apart, but I really don't want to as the computer still works perfectly.  The reason I am asking, is that when I had it repaired many years ago, the tech guy said he would like to buy it.  I asked him why, since it has only 512k of memory, and he said he would like to have it as it is, indeed, inscribed.  He did not take a photo @ the time, so I am asking if there is a record of how many cases were inscribed?
    We bought the computer from my sister-in-law who was in computer science engineering @ the University of Illinois and bought it thru the university.
    Thank You again!
    Mark

  • How to configure ADF application to use OAM Identity Assertion ? web.xml

    We have a web application developed using ADF (application development framework) and deployed on WebCenter 11.1.1.2 (weblogic 10.3.2)
    OID Authentication and OAM identity assertion is configured in WebLogic 10.3.2 .
    How to configure security in ADF application (web.xml or weblogic.xml) so that it uses OAM identity assertion (already configured as authentication providers in weblogic server)
    Any pointers or documentation so that application (developed using ADF) check for identity tocken and verifies it with one of identity assertion providers.

    John,
    I have to concur. With OAM you don't need this. OAM intercepts the calls and inserts a cookie for WLS to get user information from.
    I strongly advise to go through the above mention OFM Security Guide. Esp. Chapter 10 tells you in every detail how to implement OAM SSO with WLS (with or without OHS as a proxy).
    Reading this chapter saves you time and turnarounds on this topic...
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem in Configuring web.xml or portlet.xml

    Hi all,
    We are developing an application on the VAP 7 using Portlets.
    Can some one tell me, how to trigger a servlet from the Portlet? Rather how do i configure the web.xml or the Portlet.xml to make it identify the servlet that has to be called on load of the jsp.
    I have tried this the regular jsp and xml way (i.e. without using the Portlets and calling it from the JSP)
    I have the web.xml where i have the mapping for the single jsp ( this has the call servlet within the SRC attribute of the IMG tag. ) , also with the mapping details for the servlet to be called and this way it works fine there.
    How do i do the same for Portlets.?

    are you very new to servlets..
    ok then.
        <servlet>
            <servlet-name>bittu1</servlet-name>
            <servlet-class>Library1</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>bittu1</servlet-name>
            <url-pattern>/lop1</url-pattern>
        </servlet-mapping>
    <servlet>
            <servlet-name>bittu2</servlet-name>
            <servlet-class>Library2</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>bittu2</servlet-name>
            <url-pattern>/lop2</url-pattern>
        </servlet-mapping> i think this will help you.

  • Configure web.xml in tomcat for sub class folders

    Hi Guys,
    I am using a tomcat server. I have a package file and have created a dir in webapps called "testApp". In the classes folder, I have another folder called "CheckServlets" and within this I have 2 servlets. How can I configure my web.xml properties to get the servlets to load in a browser. I have tried the following but it doesnt work:
    <servlet>
    <servlet-name>test</servlet-name>
    <servlet-class>/CheckServlets/HelloServlet/</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>test</servlet-name>
    <url-pattern>/hello/test/</url-pattern>
    </servlet-mapping>
    So I try http://localhost:8080/testApp/hello/test but that doesnt work.

    I presume your servlet is in a package called CheckServlets?
    ie it starts something like
    package CheckServlets
    public class HelloServlet extends HttpServlet {
    }Remove the / signs from the servlet-class. This attribute should be a fully qualified class name. Like java.lang.String, or com.mypackage.servlet.MyServlet
    Given the above servlet in a package, it should be
    <servlet>
      <servlet-name>test</servlet-name>
      <servlet-class>CheckServlets.HelloServlet</servlet-class>
    </servlet>Cheers,
    evnafets

  • How to configure a JNDI ressource in the web.xml file

    Hi,
    does someone know if there is a way to configure a JNDI ressource with its parameters only in the web.xml file ?
    In my case, the JNDI ressouce is an oracle database an its conenction paramters: driverClassName, username, password, etc...
    Actually, I put everything in the configuration file of Tomcat but I would like my war file to be 100% independent of the application server.
    Thanks in advance.
    Fred.

    I wrestled with this for a long time. I may have done something wrong, but to get my mySQL JDNI reference to work, I had to add it to the server.xml file. You can try with web.xml, but I eventually just got frustrated and put it in server.xml.
    The following is between two <context> tags:
    <Resource name="jdbc/instance_name_goes_here"
                   auth="Container"
                   type="javax.sql.DataSource"/>
              <ResourceParams name="jdbc/same_instance_name_here">
                   <parameter>
                        <name>username</name>
                        <value>user_name_goes_here</value>
                   </parameter>
                   <parameter>
                        <name>password</name>
                        <value>password_goes_here</value>
                   </parameter>
                   <parameter>
                        <name>driverClassName</name>
                        <value>jdbc_fully_qualified_class_name</value>
                   </parameter>
                   <parameter>
                        <name>factory</name>
                        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                   </parameter>
                   <parameter>
                        <name>url</name>
                        <value>jdbc_connect_url_database_vendor_specific</value>
                   </parameter>
                   <parameter>
                        <name>maxActive</name>
                        <value>8</value>
                   </parameter>
                   <parameter>
                        <name>maxIdle</name>
                        <value>8</value>
                   </parameter>
              </ResourceParams>
    - Saish
    "My karma ran over your dogma." - Anon

  • Configuring a JNDI ressource in the web.xml file

    Hi,
    does someone know if there is a way to configure a JNDI ressource with its parameters only in the web.xml file ?
    In my case, the JNDI ressouce is an oracle database an its conenction paramters: driverClassName, username, password, etc...
    Actually, I put everything in the configuration file of Tomcat but I would like my war file to be 100% independent of the application server.
    Thanks in advance.
    Fred.

    I'm pretty sure you can't do it that way round. The logic of the thing is that database access URLs etc. tend to depend on the where the server is. The whole idea of these resources is to put the stuff that's specific to the server in server.xml and refer to it using names that should remain the same if you deploy your webapp on another server. Of, for example, you have test, stage and production servers running the same webapps but connecting to different databases.

  • How to read configuration data from an xml file (not web.xml)?

    Hi,
    I want to separate the application specific configuration parameters in a separate xml file and read them as and when they are needed? I know that I can use the wb.xml but I want to separate them in a different xml file because I don't want the web.xml file to be played around later after deployment. If any change is needed then it should be done in the application-config.xml.
    How can I read the parameters from this xml file in my jsp code and also what should be the location of this file if I have
    ../webapps/Root/application
    directoty structure ?
    Any help is greatly appreciated.

    can you give an example of a property file and also
    it is loaded in the jsp ?Hmm... loading properties in a JSP is not a very good idea. You should do it in a separate class, rather than mixing the logic with the display logic.
    Properties properties = new Properties();
    properties.load(UtilClass.class.getResourceAsStream("config.properties"));
    // Add a try - catch block around the load
    // for IOException...

  • Configuring web.xml for OpenSSO

    Hello!
    I am developing simple web application and want to use opensso in my web application.I have downloaded opensso,deployed and configured ,so i dont need how to configure web.xml ,what filters and jars i needed,i have the simple web.xml
    <web-app>
         <security-constraint>
              <web-resource-collection>
                   <web-resource-name>admin</web-resource-name>
                   <url-pattern>/admin/*</url-pattern>
              </web-resource-collection>
              <auth-constraint>
                   <role-name>admin</role-name>
              </auth-constraint>
         </security-constraint>
         <login-config>
              <auth-method>FORM</auth-method>
              <form-login-config>
                   <form-login-page>/login.jsp</form-login-page>
                   <form-error-page>/error.jsp</form-error-page>
              </form-login-config>
         </login-config>
         <security-role>
              <role-name>admin</role-name>
         </security-role>
    </web-app>so what filter should i add in web.xml so that when i access admins page <url-pattern>/admin/*</url-pattern>it should redirect to opensso s login page?

    Yes, I restarted the app server after making changes to web.xml file. No effects.

  • Is it possible to call a web service via UWL XML configuration?

    Hello
    Is it possible to call a web service via UWL XML configuration?
    If yes then an example would be great.
    Roy

    Hi Roy,
    Yes, yes it is possible.
    Yesterday only I came across the following document which will answer your questions:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20f4843e-314f-2a10-2a88-8c4afa20dda6?overridelayout=t…
    ~Ashvin

Maybe you are looking for

  • I go to open FCP X and iMovie opens?

    It's the strangest thing.  I can see the FCPx icon but when I open it, I get iMovie - every time.  The widows are locked in place, I have no viewer window, it wants to add all this meta-tagging, there's no cohesive timeline, it always wants to use th

  • Axis adapter receiver handle fault message

    Hi We have a Sync interface which makes a Proxy call from ECC to PI 7.3 and then PI makes Soap(Axis) Sync call to Web sevice. We are having issues when handling SOAP 1.2 fault message. Below is the actual fault response from Webserver: <env:Envelope

  • Which is better group by or for all entries in

    We have more than 11 Lac Records in AUFM table. I am working on a Report to find SO to Production Order to AUFM (for raw material). It's ALV OOP. Which code will give better result - For AUFM fetch with key AUFNR. GROUP BY matnr OR FOR ALL ENTRIES IN

  • Can I add children through functions?

    I'm working on my first basic Flash game, essentially a platformer with obstacles determined by a random number generator. The idea is that when the player character reaches a certain coordinate, the next obstacle will be created. However, I'm having

  • From CF Studio to CF Builder...

    I've developed using CF Studio for the last 11 years. Yes, 11 years. I started in January 2000 and learned on it and even when I've tried other editors I've come back to CF Studio every time. I just downloaded Builder and so far, it looks like a new