tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Taylor <paul_t...@fastmail.fm>
Subject Re: Would like to extract every request to servelt except index.html
Date Fri, 02 Apr 2010 11:05:58 GMT
Pid wrote:
> On 02/04/2010 11:09, Paul Taylor wrote:
>> Pid wrote:
>>> On 02/04/2010 09:51, Paul Taylor wrote:
>>>> I would like every request to be redirected to a central servlet 
>>>> EXCEPT
>>>> if the request is simply index.html, but at the moment everything gets
>>>> redirected to the servlet, how could I do what I want
>>>>
>>>> This is extract from my web.xml
>>>>
>>>> <servlet-mapping>
>>>> <servlet-name>SearchServerServlet</servlet-name>
>>>> <url-pattern>/</url-pattern>
>>>> </servlet-mapping>
>>>
>>> The above makes your servlet the default servlet, so it'll handle all
>>> requests that aren't handled by more specific url-patterns. The
>>> welcome files won't be processed.
>>>
>>> You could employ a Servlet Filter which analyses the requestURI and
>>> forwards to your servlet, but that calls chain.doFilter(hreq, hres)
>>> otherwise.
>>>
>>>
>> Hmm, I know why it doesnt work but i was hoping I could add something to
>> this file so that the servlet doesnt pickup index.html, is that not
>> possible.
>
> Have you found any clues in the Servlet Spec, or the Tomcat docs that 
> indicate that it _is_ possible?
>
>
> p
>
>
No, I try and stay away from config files as much as possible so Ive 
just let the servlet hande it as follows:

//If they have entered nothing, redirect to them a home page (which is 
on another server, my index.html just contained a redirect)
        if(request.getParameterMap().size()==0)
        {
            response.sendRedirect(HOME_PAGE);
            return;
        }

The idea is that if they go this server without specifying any of the 
reuired options they have probably gone to the wrong server so just send 
them to the correct server

Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message