About wls6.0 servlet mapping

          I do the wls6.0 servlet,I copy wls example helloservletExample in
          the mydomain\application\DefaultWebApp_myserver\web-inf\clsses\
          and modify the xml file
          <?xml version="1.0" ?>
          <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
          1.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
          <web-app>
          <servlet>
          <servlet-name>
          HelloWorldExample
          </servlet-name>
          <servlet-class>
          HelloWorldExample
          </servlet-class>
          </servlet>
          <servlet-mapping>
          <servlet-name>
          HelloWorldExample
          </servlet-name>
          <url-pattern>
          quickstart
          </url-pattern>
          </web-app>
          but when I run it http://localhost:7001/HelloWorldExample
          it said not found ,how can I resolve it,can anybody help me?
          

1) Make sure you specified the correct class file name. If you copied from
          our examples directory it should be
          examples.servlets.HelloWorldServlet.
          2) Also your url-pattern was set to quickstart. So you should point y our
          browser to http://localhost/HelloWorldExamples/quickstart
          Read our docs
          Kumar
          blackwhites wrote:
          > I do the wls6.0 servlet,I copy wls example helloservletExample in
          > the mydomain\application\DefaultWebApp_myserver\web-inf\clsses\
          > and modify the xml file
          > <?xml version="1.0" ?>
          > <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
          > 1.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
          > <web-app>
          > <servlet>
          > <servlet-name>
          > HelloWorldExample
          > </servlet-name>
          > <servlet-class>
          > HelloWorldExample
          > </servlet-class>
          > </servlet>
          > <servlet-mapping>
          > <servlet-name>
          > HelloWorldExample
          > </servlet-name>
          > <url-pattern>
          > quickstart
          > </url-pattern>
          > </web-app>
          > but when I run it http://localhost:7001/HelloWorldExample
          > it said not found ,how can I resolve it,can anybody help me?
          

Similar Messages

  • A problem with servlet  mapping , using a servlet to produce some chart in

    Hi
    Thank you for reading my post.
    My problem is about using a Chart library which works well in jsf application but it does not works in JSF portlets.
    I think i find the problem but i do not know the solution.
    to use this charting library we should add a servlet to web.xml
    something like :
    <servlet>
    <servlet-name>Jenia internal servlet</servlet-name>
    <servlet-class>org.jenia.faces.util.Servlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Jenia internal servlet</servlet-name>
    <url-pattern>/jenia4faces/*</url-pattern>
    </servlet-mapping>
    so , when we try to load a chart , it will make the chart image source
    something like
    http://localhost:28080/Adv/jenia4faces/chart/OAReport.jspBarChart3d_id0.png
    in the above sample , adv is the name of web application which is
    deployed in a servlet container.
    and filter applied to make the chart render-able.
    to use the chart library in jsf portlet , i add the servlet
    description as i did for web application , so i add
    <servlet>
    <servlet-name>Jenia internal servlet</servlet-name>
    <servlet-class>org.jenia.faces.util.Servlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Jenia internal servlet</servlet-name>
    <url-pattern>/jenia4faces/*</url-pattern>
    </servlet-mapping>
    to my portlet web.xml file.
    when we have portlet , the url to access that portlet (which indeed is a
    web application) changes
    for example
    url for a sample portlet with same web application name
    will be like
    http:// localhost:28080/pluto/portal/Adv/
    as you can see there are some prefix to web application name in the url
    , but when i use chart component to show
    same chart , it still look for the chart in url like :
    http://localhost:28080/Adv/jenia4faces/chart/OAReport.jspBarChart3d_id0.png
    As you may already sugest , the image will not render because browser is
    looking in wrong place.
    now i
    think if i find some way to map that servlet to correct url
    pattern it will works.
    my question is :
    1-what will be new servlet url pattern ?
    2-is my assumption correct ?
    Thank you very much for reading such a long post

    i wrote an app i.e servlet which would select the data from the database and retrive the data.but i want to send this data to normal java file(which is not a servlet) and i want to display results in the normal java file.
    can any body help this concept........
    send me mail:[email protected]

  • Questions about Java Servlets and JSP

    Hi,
    I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
    I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
    I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
    I have a few questions:
    How should I start to learn JS and JSP?
    How applicable will the java knowlegdge I have already be?
    Are JSP common on the world wide web?
    What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
    Is it likey my web host (and others) will support JSP?
    Thank-you very much for helping a novice get started,
    Regards,
    Paul

    Hi, Steve ...has to be frustrating! But do not despair.
    Let's suppose the servlet it's named MyServlet on package org.servlets
    WEB-INF should look:
    WEB-INF
    classes
    org
    servlets
    MyServlet.class
    web.xml
    web.xml file should have this two declarations:
    <web-app>
      <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>org.servlets.MyServlet</servlet-class>
      </servlet>
      <!-- other servlets -->
      <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/MyServlet</url-pattern>
      </servlet-mapping>
      <!-- other servlets mappings -->
    </web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
    http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
    Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing.

  • Newbie question about loading servlets on tomcat

    I have what is probably a very basic question about loading simple servlets on to tomcat to test its installation. I have followed instructions from numerous tutorials to the letter but still I can't get it to work.
    I have installed tomcat on win2k in c:\tomcat. I set up the jdk, environment vars (JAVA_HOME, CATALINA_HOME, TOMCAT_HOME) which all point at the correct dirs. I can compile a servlet without errors. I can also place a test jsp and html file into the root directory and they both work fine.
    However, now I am trying a test servlet and no matter what I do it gives me a 404. I have a servlet class file called "HelloServlet.class" which I placed into the %install_dir%\webapps\ROOT\WEB-INF\classes directory. I try to reference it using this url:
    http://localhost/servlet/HelloServlet
    Tomcat is configured to use port 80 and has been restarted after adding the servlet class file. Does anyone have a clue why this is not working for me?
    Many thanks
    Marc

    You have to add in the web.xml file that it is in the WEB-INF dir, the information about your servlet. An example:
    <web-app>
    <servlet>
    <servlet-name>HelloServlet</servlet-name>
    <servlet-class>HelloServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloServlet</servlet-name>
    <url-pattern>/HelloServlet</url-pattern>
    </servlet-mapping>
    </web-app>

  • Setting servlet mapping?

    a newbie question:
    My servlet are running fine when requested by:
    http://myMachine.com:7777/j2ee/servlet/com.whatever.MyServlet
    However I want it to be reached by:
    http://myMachine.com:7777/servlet/com.whatever.MyServlet
    note the missing "/j2ee". What is the proper way to set this mapping of the servlet directory?
    I assume it might be done in the according web.xml?
    Is it clever to edit web.xml manually? Do I have to use dcmctl udateconfig
    afterwards?
    Any hints are appreciated!

    I see what you mean. WebContent is just a general name. I use maven for building, which uses webapp as a standard.
    As far as having pages in a faces directory, that should be the case. I'm using /faces/* for the servlet mapping in my web.xml. Any requested url with that pattern should map the request to the faces servlet. Whatever page replaces the * would then be located in the root of the webapp directory by the faces servlet.
    My app doesn't seem to be getting that far. The /faces request doesn't seem to be getting to the faces servlet, as there are no initialization lines being dumped to my log file, but when I use *.jsf, it does.

  • Can i run a servlet without a web.xml file for servlet mapping?

    Hello everyone.
    The code i want to run compiles and everythink looks ok.
    It produces the .class file.
    I run Tomcat 4.1 and i build my Web site with Dreamweaver.
    I have a form in a page and i want to send the data upon form completion to a database i already have build with MySql.
    The database is up and running and the server is set-up ok.
    I have changed the port in Tomcat to run on port 80.
    The directory i have my site is
    Tomcat41\webapps\ROOT\se
    and the directory where i keep the servlet class is
    Tomcat41\webapps\ROOT\se\WEB-INF\servlet
    I have a web.xml file to map the servlet and placed it in
    Tomcat41\webapps\ROOT\se\WEB-INF
    In the Form action i write action:"/servlets/Classes/GroupRegistration"
    and I RECEIVE AN 404 ERROR FROM APACHE.
    Somethink is wrong .
    The following is the code from the GroupRegistration.java file
    and follws the web.xml file.
    Please Help.
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class GroupRegistration extends HttpServlet
    Connection con;
    public void doPost (HttpServletRequest req, HttpServletResponse res)
                             throws ServletException, java.io.IOException
         handleForm(req, res);
    public void init() throws ServletException {
         try{
         /* Loading the driver for the database */
         Class.forName("com.mysql.jdbc.Driver");
         Connection Con = DriverManager.getConnection("jdbc:mysql://localhost/se?user=luser&password=");
         catch (ClassNotFoundException e) {
         throw new UnavailableException("Couldn't load JdbcOdbcDriver");
         catch (SQLException e) {
         throw new UnavailableException("Couldn't get db connection");
         private void handleForm(HttpServletRequest req, HttpServletResponse res)
         throws ServletException {
         //ServletOutputStream out = res.OutputStream();
         //res.setContentType("text/html");
         //Extract the form Data Here
         String group = req.getParameter("GroupNo");
         String Name1 = req.getParameter("Name1");
         String LoginID1 = req.getParameter("LoginID1");
         String Name2 = req.getParameter("Name2");
         String LoginID2 = req.getParameter("LoginID2");
         String Name3 = req.getParameter("Name3");
         String LoginID3 = req.getParameter("LoginID3");
         String Name4 = req.getParameter("Name4");
         String LoginID4 = req.getParameter("LoginID4");
         String URL = req.getParameter("URL");
         String Title2 = req.getParameter("Title2");
         String date = req.getParameter("date");
         String INSERT = "INSERT INTO registration (groupno, name1, loginid1, name2, loginid2, name3, loginid3, name4, loginid4, url, topic, date) VALUES (" + group + "," + Name1 + "," + LoginID2 + "," + Name2 + "," + LoginID2 + "," + Name3 + "," + LoginID3 + "," + Name4 + "," + LoginID4 + "," + URL + "," + Title2 + "," + date + ")";
         PreparedStatement pstmt = null;
         try{
         pstmt = con.prepareStatement(INSERT);
         pstmt.executeUpdate();
         catch (SQLException e) {
         throw new ServletException(e);
         finally {
         try {
         if (pstmt != null)pstmt.close();
         catch (SQLException ignored){
    The web.xml file
    <?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">
    <servlet>
    <servlet-name>GroupRegistration</servlet-name>
    <servlet-class>GroupRegistration</servlet-class>
    </servlet>
    <servlet-maping>
    <servlet-name>GroupRegistration</servlet-name>
    <url-pattern>/myGroupRegistration</url-patern>
    </servlet-mapping>
    </web-app>
    I apreciate your time.
    Thanks for any help.

    and the directory where i keep the servlet class is
    Tomcat41\webapps\ROOT\se\WEB-INF\servletOthers have pointed out that "servlet" should be "classes", but there is another mistake that hasn't been spotted. If you want your servlet to appear in the root context, you should use:
    Tomcat41\webapps\ROOT\WEB-INF\classes
    If you want your servlet to appear under the /se context, then you should use:
    Tomcat41\webapps\se\WEB-INF\classes
    and also, in the latter case, your form action should be /se/myGroupRegistration.

  • How to specify  a servlet mapping as the url pattern with in the security constraints

    Hi ,
    Weblogic 6.0 documentation says the following:-
    Define which resources in the Web Application the security constraint applies to using the <url-pattern> element that is nested inside the <web-resource-collection> element. The <url-pattern> can refer to either a directory, filename or a <servlet-mapping>.
    To apply the security constraint to the entire Web Application, use the following <url-pattern>:
    <url-pattern>/*</url-pattern>
    Could any one let me know how to specify servlet mapping as the url pattern.
    I tried various combination and it doesn't seem to work and any help in this regard will be greatly appreciated.
    Thanks
    kannan

    The answer is posted here:
    Unapproved User Flag in UME

  • Problems with servlet mapping in 10g AS

    Hi There,
    i have a web application consisting of 2 controller servlets and use url mapping to send requests to the appropriate servlet, but i have a strange issue with 10g where it seems to be alternating between serlvets when handling requests!!!!
    the web.xml is like as follows (with the app having the root context '/app'):
    <servlet>
    <servlet-name>control1</servlet-name>
    <servlet-class>com.package1.class.name</servlet-class>
    </servlet>
    <servlet>
    <servlet-name>control2</servlet-name>
    <servlet-class>com.package2.class.name</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>control2</servlet-name>
    <url-pattern>/special/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
    <servlet-name>control1</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    therefore i'd expect a request like http://domain.name/app/special/content to be handled by the control2 servlet and http://domain.name/app/normal/content or http://domain.name/app/normal/special/content to be handled by the control1 servlet...
    but what seems to happen when requesting http://domain.name/app/special/content oc4j seems to alternate which servlet it passes it to...
    is there any reason why this might be happening (like some app server configuration), as i have other applications that are configured in the same way, and there's no problems with requests going to the wrong servlet.
    many thanks for your help,
    Andy

    In your integration process, define the import parameter under Configurable Parameters category.
    http://help.sap.com/saphelp_nwpi71/helpdata/en/44/1f1a5c932d0d19e10000000a114a6b/frameset.htm
    Regards,
    Prateek

  • Re: issue with servlet-mapping

    Hello,
    i got following url pattern on web xml and it works fine on resin, however,
    its gives me, java.lang.IllegalArgumentException: Invalid pattern,
    is there is a anyway to fix it without altering the file structure.
    <servlet-mapping>
            <servlet-name>FacesServlet</servlet-name>
            <url-pattern>/jsf/*.jsf</url-pattern>
        </servlet-mapping>

    Wildcards(*) can be used either at the beginning or end of the pattern.You cannot specify wildcards in the middle of the pattern.
    So, only either of these will work
    <servlet-mapping>
       <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>Or
    <servlet-mapping>
       <servlet-name>FacesServlet</servlet-name>
       <url-pattern>/jsf/*</url-pattern>
    </servlet-mapping>

  • Bug in servlet mapping

              Hi, it appears that the servlet mapping specified in section 10 of the
              Servlet 2.2 spec is broken in Weblogic server 6.0 GA. Here is the servlet
              2.2. spec for mapping:
              10.1 Use of URL Paths
              Servlet containers must use URL paths to map requests to servlets. The
              container uses the
              RequestURI from the request, minus the Context Path, as the path to map to a
              servlet. The URL
              path mapping rules are as follows (where the first match wins and no further
              rules are attempted):
              1. The servlet container will try to match the exact path of the request to
              a servlet.
              2. The container will then try to recursively match the longest path prefix
              mapping. This process
              occurs by stepping down the path tree a directory at a time, using the '/'
              character as a path
              separator, and determining if there is a match with a servlet.
              3. If the last node of the url-path contains an extension (.jsp for
              example), the servlet container
              will try to match a servlet that handles requests for the extension. An
              extension is defined as the
              part of the path after the last '.' character.
              4. If neither of the previous two 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 in this case.
              It appears that Weblogic does step #3 before step #2. This means that if
              you have a servlet called 'foo' mapped to '/foo/*' and Weblogic 6.0 receives
              a request for '/foo/bar.jsp', the container returns an error because it
              cannot find a JSP file called "bar.jsp" to compile, when according to the
              spec, servlet 'foo' should receive the request with the pathInfo value set
              to "/bar.jsp".
              The workaround is to assign all *.jsp files to the servlet 'foo' as well,
              but this breaks all other JSP files in the same web application.
              I consider this a bad bug, as it breaks a proxy server that I have been
              working on. Tomcat and other servlet containers seem to have gotten this
              right, why not Weblogic?
              Thanks
              Colin Evans
              Colin Evans
              Senior Engineer
              BITMO, Inc. (http://www.bitmo.com)
              (415)920.7225 / [email protected]
              

              Hi, it appears that the servlet mapping specified in section 10 of the
              Servlet 2.2 spec is broken in Weblogic server 6.0 GA. Here is the servlet
              2.2. spec for mapping:
              10.1 Use of URL Paths
              Servlet containers must use URL paths to map requests to servlets. The
              container uses the
              RequestURI from the request, minus the Context Path, as the path to map to a
              servlet. The URL
              path mapping rules are as follows (where the first match wins and no further
              rules are attempted):
              1. The servlet container will try to match the exact path of the request to
              a servlet.
              2. The container will then try to recursively match the longest path prefix
              mapping. This process
              occurs by stepping down the path tree a directory at a time, using the '/'
              character as a path
              separator, and determining if there is a match with a servlet.
              3. If the last node of the url-path contains an extension (.jsp for
              example), the servlet container
              will try to match a servlet that handles requests for the extension. An
              extension is defined as the
              part of the path after the last '.' character.
              4. If neither of the previous two 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 in this case.
              It appears that Weblogic does step #3 before step #2. This means that if
              you have a servlet called 'foo' mapped to '/foo/*' and Weblogic 6.0 receives
              a request for '/foo/bar.jsp', the container returns an error because it
              cannot find a JSP file called "bar.jsp" to compile, when according to the
              spec, servlet 'foo' should receive the request with the pathInfo value set
              to "/bar.jsp".
              The workaround is to assign all *.jsp files to the servlet 'foo' as well,
              but this breaks all other JSP files in the same web application.
              I consider this a bad bug, as it breaks a proxy server that I have been
              working on. Tomcat and other servlet containers seem to have gotten this
              right, why not Weblogic?
              Thanks
              Colin Evans
              Colin Evans
              Senior Engineer
              BITMO, Inc. (http://www.bitmo.com)
              (415)920.7225 / [email protected]
              

  • Different behaviour on servlet w/o servlet-mapping and init parameters

    I was playing around and found, that the init-parameter of a servlet is always null if there is no servlet mapping. I did not define a servlet mapping because I used the servlet only for for (named) dispatching (client usage should not be allowed).
    web.xml:
    <?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">
      <servlet>
        <servlet-name>InitParamServlet</servlet-name>
        <servlet-class>test.InitParamServlet</servlet-class>
        <init-param>
          <param-name>param1</param-name>
          <param-value>value1</param-value>
        </init-param>
      </servlet>
      <servlet-mapping>
        <servlet-name>InitParamServlet</servlet-name>
        <url-pattern>*.initparam</url-pattern>
      </servlet-mapping>
    </web-app>
    InitParamServlet.java:
    package test;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class InitParamServlet extends HttpServlet{
      private static final long serialVersionUID = 1L;
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter pw = response.getWriter();
        pw.write(getServletName());
        pw.write(": param1=" + getInitParameter("param1"));
    }The URL http://localhost:8080/xxx/servlet/test.InitParamServletreturns org.apache.catalina.INVOKER.test.InitParamServlet: param1=null
    (on Tomcat), and the call to the same servlet with URL http://localhost:8080/xxx/test.initparamreturns InitParamServlet: param1=value1 instead (the correct init parameter value)!
    The same happens with jetty. This looks strange for me; I would expect the same behaviour for the servlet (independent from servlet-mapping-tag in the web.xml).

    When you call the url
    http://localhost:8080/xxx/servlet/test.InitParamServlet
    you are actually calling the invoker servlet that is defined in the default conf/web.xml. If you look at this web.xml file you will see that the invoker is mapped with the pattern "/servlet/*" which maps to the above url. The request goes to this servlet which parses the url and then calls the InitParamServlet class.
    When you call the url
    http://localhost:8080/xxx/test.initparam
    you are matching the url pattern you defined in the WEB-INF/web.xml file ("*.initparam"). This time the request goes to servlet instance that you defines in the servlet naming tags as "InitParamServlet" and since you defined init params they are populated.
    Note that these urls will also match the "*.initparam" pattern
    http://localhost:8080/xxx/XXXXX.initparam
    http://localhost:8080/xxx/badpackage.initparam
    http://localhost:8080/xxx/A.initparam
    Most people would have simplely defined the second servlet mapping as "initparam" and accessed the servlet with the url
    http://localhost:8080/xxx/initparam

  • Invalid element 'servlet-mapping' in content of 'web-app'

    Hello, JDev gurus!
    When compling, JDev 9.0.2.822 produce following error
    "oracle.xml.parser.v2.XMLParseException: Invalid element 'servlet-mapping' in content of 'web-app', expected elements '[taglib, resource-ref, security-constraint, login-config, security-role, env-entry, ejb-ref]'."
    on line <%@ taglib uri="http://xmlns.oracle.com/bibeans" prefix="orabi" %>
    This line was added automatically from component palette.
    How can I resolve this error?

    Hi,
    Did you change something into your web.xml file?
    Look at your web.xml. You must preserve the order given by the error message:
    Servlet-mapping
    session-config
    mime-mapping
    ejb-ref
    Jamil

  • Servlet mapping with Apache + Tomcat

    I'm trying to set up my servlet with apache + Tomcat(3.2.3), and i'm using mod_jk as the Tomcat-Apache plug-in.
    The HelloWorld servlet that comes with the examples app worked fine at: http://localhost/examples/servlet/HelloWorldExample,
    but how do I change the configurations, so that it can be invoked at:
    http://localhost/examples/HelloWorldExample ?
    It appears to me that '/servlet/' is the default prefix for Tomcat's RequestInterceptor, there is no way to get around that.
    Any insights will be greatly appreciated, thanks!
    Elaine

    hi
    Try this:
    add below code in web.xml file in examples/WEB-INF
    F directory
    <servlet-mapping>
    <servlet-name>
    HelloWorldExample
    </servlet-name>
    <url-pattern>
    /HelloWorldExample
    </url-pattern>
    </servlet-mapping>
    Thanks for the reply, the web.xml is already set up this way, in fact, I'm able to invoke the servlet through tomcat(running on port 8080): http://localhost:8080/examples/HelloWorldExample,
    tomcat reads the web.xml without any problems.
    The problem comes from Apache(port 80), http://localhost:80/examples/HelloWorldExample wouldn't work, only http://localhost:80/examples/servlet/HelloWorldExample works.
    It appears to me that when requests are relayed from Apache to tomcat, you need to tell tomcat that you intend to invoke a servlet by prefixing '/servlet/', if you look in the server.xml, it has
    <RequestInterceptor
    className="org.apache.tomcat.request.InvokerInterceptor"
    debug="0" prefix="/servlet/" />
    I've tried to change this to something else, it didn't seem to make any difference.

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

  • Quick question about url/jsp mapping

    Could anyone clarify whether the following mapping in the web.xml file is possible?
    I want to access the file webapps\examples\gate\login.jsp by going to the page http://192.168.2.143:8080/work/login.jsp instead of http://192.168.2.143:8080/examples/gate/login.jsp
    Currently I can map it fine to http://192.168.2.143:8080/examples/work/login.jsp,
    which is an existing folder, but when I try and get it above the examples folder, it gives me the 404 error.
        <servlet>
            <servlet-name>Login</servlet-name>
            <jsp-file>/gate/login.jsp</jsp-file>
        </servlet>
        <servlet-mapping>
            <servlet-name>Login</servlet-name>
            <url-pattern>/../work/login.jsp</url-pattern>
        </servlet-mapping>

    Using only work/login.jsp will cause an error, and the tomcat server to crash, if I use the pattern
    <url-pattern>/work/login.jsp</url-pattern>, I just map the URL http://192.168.2.143:8080/examples/work/login.jsp instead of
    http://192.168.2.143:8080/examples/gate/login.jsp
    My entire webaps structure is rather long, and contains code other than my own, so I'd rather not post it, I just need to figure out if it is possible to map the jsp page to a path above the file. (do you think I need to do it in another web.xml?)

Maybe you are looking for

  • Can I make the little white box with the cross in it disappear?

    Layout mode. There is a tiny little square with cross in it, at bottom of text box. Cool. Sometimes it's there, sometimes it's not. Is there a way to make that little box disappear? So I can view the page as it will print out? I'm making graphic imag

  • The quantity received/required for each material (only sum of Dep and Foreq

    Hi all I have a report and I need it to show the <b>quantity received/required</b> for each material (<b>only sum of Depreq and ForReq</b>) in a plant due to MRP execution. Basically something like MD04 showing each MRP element entry (only sum of Dep

  • Opening external files

    Hello, im starting in flash, and i want to open external files with buttons, for a cd menu that i'm creating. I have created an fscommand folder and a launcher.bat that execute the file that i want when i press the button. But what i really want is t

  • How to reset Safari 8.0.3?

    I want to reset my safari because the homepage was changed by adware (I removed the adware) and I do not know how to get it back to the default. Thanks x

  • Fade out MP3 individually

    Tie this code to a button, if I repetitive press as  fast as I can, an error exception would appear in the application. I  found that it would not throw an error if I stop the sound when it  completely fade out. However, I wish the fade out function