Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

url-pattern for base page of site in web.xml

i have application on url "http://game.appspot.com/". i need to call a servlet from this base root,it means that relative path to call the servlet should be "/" , but it is not working when i do :

<url-pattern>/</url-pattern>

in my web.xml file , and i can' t leave it empty like :

<url-pattern></url-pattern>

because there is an error when i am tryiing to deploy it to google app engine.

what should i do?

thank you!

like image 570
michael_u Avatar asked Nov 03 '22 09:11

michael_u


1 Answers

There appears to be an older way of doing this with a welcome file servlet hack:

From http://www.coderanch.com/t/359995/Servlets/java/Servlets-Mapping-root-path-exclusively:

<servlet>
  <description></description>
  <display-name>test</display-name>
  <servlet-name>test</servlet-name>
  <servlet-class>Test</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>test</servlet-name>
  <url-pattern>*.html</url-pattern>
</servlet-mapping>

<welcome-file-list>
  <welcome-file>index.html</welcome-file>
</welcome-file-list>

If you use index.html you'll need to have index.html on disk, even as a 0-byte file, in order for the servlet to get executed. I'd recommend setting the url-pattern to some other file extension, maybe *.xyz and then have a 0 byte index.xyz on disk associated with your servlet (I haven't tested that but it should work).

like image 191
cfeduke Avatar answered Nov 08 '22 03:11

cfeduke