Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gyrex-dev] Having a Servlet and a Resource with the same "/" (Root) Alias

Hi Gunnar,
a question regarding the aliases of servlets and resources and what the best solution would be:

My Problem: 
1. I have servlet "WelcomeController" with the default alias "welcome" so that I can call it by http://localhost:8080/mysampleapp1/welcome
2. I now also want to be that my default servlet, so that I can call with with http://localhost:8080/mysampleapp1/
3. to achieve 2. I have registered a new Servlet with the alias "/" which also points to the same WelcomeController servlet.  That works, but see 4.
4. I also have a resource registered for the alias "/" which points to my public folder to get images and css etc. 

When I now call http://localhost:8080/mysampleapp1/ I see the output of the WelcomeController which is what I expect. But it also seems that the "/" resource isn't working anymore, because now my image on that page doesn't display anymore.
I debugged it and found that when the image URL is called (http://localhost:8080/mysampleapp1/images/logo.png) it now alos tries to route that to the WelcomeController. 

How can I achieve that I have something like a default servlet for the alias "/" and also having all my resources also under this alias "/" ?


Here are the extension points of the plugin.xml of my example app. I am only talking about application1 here. 

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.gyrex.http.applications">
      <application
            contextPath="/christoph"
            id="org.eclipse.gyrex.sample1.application1">
      </application>
      <mount
            applicationId="org.eclipse.gyrex.sample1.application1"
            url="">
      </mount>
      <servlet
            alias="/"
            applicationId="org.eclipse.gyrex.sample1.application1"
            class="org.eclipse.gyrex.sample1.WelcomeController">
      </servlet>
      <servlet
            alias="/welcome"
            applicationId="org.eclipse.gyrex.sample1.application1"
            class="org.eclipse.gyrex.sample1.WelcomeController">
      </servlet>
      <mount
            applicationId="org.eclipse.gyrex.sample1.application2"
            url="">
      </mount>
      <servlet
            alias="/welcome"
            applicationId="org.eclipse.gyrex.sample1.application2"
            class="org.eclipse.gyrex.sample1.WelcomeController">
      </servlet>
      <application
            contextPath="/gunnar"
            id="org.eclipse.gyrex.sample1.application2">
      </application>
      <resource
            alias="/"
            applicationId="org.eclipse.gyrex.sample1.application1"
            path="public/">
      </resource>
   </extension>

</plugin>



Thanks
Christoph

Back to the top