0

web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>TestFilter1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>



<servlet>
    <servlet-name>ser1</servlet-name>
    <servlet-class>com.gaurav.test.Hello</servlet-class>    
</servlet>

<servlet-mapping>
    <servlet-name>ser1</servlet-name>
    <url-pattern>/</url-pattern>    
</servlet-mapping>

</web-app>

index.html

<body>
HelLoSTHTML
</body>

index.jsp

<body>
HelLoSTJSP
</body>

Hello.java,implementing javax.servlet.Servlet

service method

PrintWriter out=paramServletResponse.getWriter();
out.println("HelloTextStart");
out.println(config);
out.println("HelloTextEnd");
out.close();

deployed on jboss-5.1.0GA

now cases

  1. **requesting

    /TestFilter1/

    ** showing

    "HelloTextStart org.apache.catalina.core.StandardWrapperFacade@1a878065 HelloTextEnd "

    but not showing

    "HelLoSTHTML"

  2. **requesting

    /TestFilter1/index.html

    ** then also showing

    "HelloTextStart org.apache.catalina.core.StandardWrapperFacade@1a878065 HelloTextEnd "

    but not showing

    "HelLoSTHTML"

  3. **requesting

    /TestFilter1/index.jsp

    ** showing

    "HelLoSTJSP"

So what is the order of processing/prioritizing this request? (html,jsp.Servlet ser1)

gprathour
  • 14,813
  • 5
  • 66
  • 90
shrotriya
  • 26
  • 4

2 Answers2

0

Your application works as configured. You tell to your webapp : When you see request coming send them to the servlet class com.gaurav.test.Hello

Conf:

<servlet>
    <servlet-name>ser1</servlet-name>
    <servlet-class>com.gaurav.test.Hello</servlet-class>    
</servlet>

<servlet-mapping>
    <servlet-name>ser1</servlet-name>
    <url-pattern>/</url-pattern>    
</servlet-mapping>

So this servlet is responding to your request. I think want you need is to configure the servlet javax.servlet.Servlet

I hope this will help

Pracede
  • 4,226
  • 16
  • 65
  • 110
0

we can configure the URL-patterns in 3 ways

1) Absolute/Exact Matching (Ex: <url-pattern>/test1</url-pattern>)
2) Extension Matching      (Ex: <url-pattern>*.do</url-pattern>)
3) Directory Matching      (Ex: <url-pattern>/abc/*</url-pattern>)

<url-pattern>/</url-pattern> means Every Request go to Hello.java

First it will check Exact matching then Extension there after Directory Matching.

Above code for every request is going to Hello.java.

go through this link you will get clarity which one will be given priority in Tomcat 6: index.html or index.jsp?

Community
  • 1
  • 1
user1990992
  • 87
  • 3
  • 13
  • when i am trying /TestFilter1/index.html the it should go to that index.html file? – shrotriya Jul 09 '14 at 13:25
  • and welcome file list have index.html. /TestFilter1/ should search first from welcome file list? and if it do so, it'll find index.html file – shrotriya Jul 09 '14 at 13:26