|
|
|
|
Re: URGENT: configure Jetty to load index.html when http://localhost is given [message #124595 is a reply to message #124484] |
Thu, 15 January 2009 08:54  |
Eclipse User |
|
|
|
Simon, I had just copied ResourceServlet to my project and added the 2
lines as shown below between <Walter> .
Basically the default page could be retrieved from init params of servlet
definition from plugin.xml and can be used instead of "/index.html".
I am not sure if this is the right solution. However, it worked for my web
page http://www.propertymapz.com
public void service(ServletRequest req, ServletResponse resp) throws
ServletException, IOException {
HttpServletRequest httpRequest = (HttpServletRequest) req;
HttpServletResponse httpResponse = (HttpServletResponse) resp;
String method = httpRequest.getMethod();
if (method.equals("GET") || method.equals("POST") ||
method.equals("HEAD")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
String resourcePath = internalName + httpRequest.getPathInfo();
// <Walter>
if ( "/".equals ( resourcePath ) )
resourcePath = "/index.html" ;
// <Walter>
if (!writeResource(httpRequest, httpResponse, resourcePath)) {
httpResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
} else
httpResponse.setStatus(HttpServletResponse.SC_METHOD_NOT_ALL OWED);
}
"Simon Kaegi" <simon_kaegi@ca.ibm.com> wrote in message
news:gkl3de$a50$1@build.eclipse.org...
> Walter,
>
> If you have a decent implementation of WelcomeServlet would you consider
> sharing it.
> It would be good to iterate on a solution here and I'd like to help to get
> one canonical solution that's bug-free for this problem and then add it
> back into org.eclipse.equinox.http.helpers.
>
> -Simon
>
>
> "Walter Prabhakar" <kwchess@gmail.com> wrote in message
> news:gkkv33$1vo$1@build.eclipse.org...
>> Thanks Simon. It works.
>>
>> "Simon Kaegi" <simon_kaegi@ca.ibm.com> wrote in message
>> news:gki9k0$jkk$1@build.eclipse.org...
>>> The OSGI Http Service does not directly support "welcome files". If you
>>> want to support this you can do this yourself by taking and customizing
>>> the ResourceServlet. See org.eclipse.equinox.http.helpers in the Equinox
>>> Incubator (Currently in /cvsroot/eclipse/equinox-incubator but will
>>> eventually be moving to the RT incubator).
>>>
>>> -Simon
>>>
>>> "Walter Prabhakar" <kwchess@gmail.com> wrote in message
>>> news:gkact4$l5l$1@build.eclipse.org...
>>>> How to configure jetty to load index.html by default when hitting
>>>> http://localhost
>>>>
>>>> Thanks
>>>> - Walter.
>>>>
>>>>
>>>
>>>
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.28095 seconds