[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.equinox] Re: URGENT: configure Jetty to load index.html when http://localhost is given

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_ALLOWED);
}




"Simon Kaegi" <simon_kaegi@xxxxxxxxxx> wrote in message news:gkl3de$a50$1@xxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxx> wrote in message news:gkkv33$1vo$1@xxxxxxxxxxxxxxxxxxxx
Thanks Simon.  It works.

"Simon Kaegi" <simon_kaegi@xxxxxxxxxx> wrote in message news:gki9k0$jkk$1@xxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxx> wrote in message news:gkact4$l5l$1@xxxxxxxxxxxxxxxxxxxx
How to configure jetty to load index.html by default when hitting http://localhost

Thanks
- Walter.