302344 Make the list of available contexts if root context is not configured optional
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1761 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
4d72f12fa1
commit
7b82292ff0
|
@ -1,4 +1,5 @@
|
|||
jetty-7.1.1-SNAPSHOT
|
||||
+ 302344 Make the list of available contexts if root context is not configured optional
|
||||
+ 304803 Remove TypeUtil Integer and Long caches
|
||||
+ 308857 Update test suite to JUnit4 - Module jetty-jndi
|
||||
+ 308856 Update test suite to JUnit4 - Module jetty-jmx
|
||||
|
|
|
@ -50,6 +50,7 @@ public class DefaultHandler extends AbstractHandler
|
|||
final long _faviconModified=(System.currentTimeMillis()/1000)*1000;
|
||||
byte[] _favicon;
|
||||
boolean _serveIcon=true;
|
||||
boolean _showContexts=true;
|
||||
|
||||
public DefaultHandler()
|
||||
{
|
||||
|
@ -114,44 +115,47 @@ public class DefaultHandler extends AbstractHandler
|
|||
writer.write("<HTML>\n<HEAD>\n<TITLE>Error 404 - Not Found");
|
||||
writer.write("</TITLE>\n<BODY>\n<H2>Error 404 - Not Found.</H2>\n");
|
||||
writer.write("No context on this server matched or handled this request.<BR>");
|
||||
writer.write("Contexts known to this server are: <ul>");
|
||||
|
||||
|
||||
Server server = getServer();
|
||||
Handler[] handlers = server==null?null:server.getChildHandlersByClass(ContextHandler.class);
|
||||
|
||||
for (int i=0;handlers!=null && i<handlers.length;i++)
|
||||
|
||||
if (_showContexts)
|
||||
{
|
||||
ContextHandler context = (ContextHandler)handlers[i];
|
||||
if (context.isRunning())
|
||||
writer.write("Contexts known to this server are: <ul>");
|
||||
|
||||
Server server = getServer();
|
||||
Handler[] handlers = server==null?null:server.getChildHandlersByClass(ContextHandler.class);
|
||||
|
||||
for (int i=0;handlers!=null && i<handlers.length;i++)
|
||||
{
|
||||
writer.write("<li><a href=\"");
|
||||
if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
||||
writer.write("http://"+context.getVirtualHosts()[0]+":"+request.getLocalPort());
|
||||
writer.write(context.getContextPath());
|
||||
if (context.getContextPath().length()>1 && context.getContextPath().endsWith("/"))
|
||||
writer.write("/");
|
||||
writer.write("\">");
|
||||
writer.write(context.getContextPath());
|
||||
if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
||||
writer.write(" @ "+context.getVirtualHosts()[0]+":"+request.getLocalPort());
|
||||
writer.write(" ---> ");
|
||||
writer.write(context.toString());
|
||||
writer.write("</a></li>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.write("<li>");
|
||||
writer.write(context.getContextPath());
|
||||
if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
||||
writer.write(" @ "+context.getVirtualHosts()[0]+":"+request.getLocalPort());
|
||||
writer.write(" ---> ");
|
||||
writer.write(context.toString());
|
||||
if (context.isFailed())
|
||||
writer.write(" [failed]");
|
||||
if (context.isStopped())
|
||||
writer.write(" [stopped]");
|
||||
writer.write("</li>\n");
|
||||
ContextHandler context = (ContextHandler)handlers[i];
|
||||
if (context.isRunning())
|
||||
{
|
||||
writer.write("<li><a href=\"");
|
||||
if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
||||
writer.write("http://"+context.getVirtualHosts()[0]+":"+request.getLocalPort());
|
||||
writer.write(context.getContextPath());
|
||||
if (context.getContextPath().length()>1 && context.getContextPath().endsWith("/"))
|
||||
writer.write("/");
|
||||
writer.write("\">");
|
||||
writer.write(context.getContextPath());
|
||||
if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
||||
writer.write(" @ "+context.getVirtualHosts()[0]+":"+request.getLocalPort());
|
||||
writer.write(" ---> ");
|
||||
writer.write(context.toString());
|
||||
writer.write("</a></li>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.write("<li>");
|
||||
writer.write(context.getContextPath());
|
||||
if (context.getVirtualHosts()!=null && context.getVirtualHosts().length>0)
|
||||
writer.write(" @ "+context.getVirtualHosts()[0]+":"+request.getLocalPort());
|
||||
writer.write(" ---> ");
|
||||
writer.write(context.toString());
|
||||
if (context.isFailed())
|
||||
writer.write(" [failed]");
|
||||
if (context.isStopped())
|
||||
writer.write(" [stopped]");
|
||||
writer.write("</li>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,6 +187,15 @@ public class DefaultHandler extends AbstractHandler
|
|||
{
|
||||
_serveIcon = serveIcon;
|
||||
}
|
||||
|
||||
public boolean getShowContexts()
|
||||
{
|
||||
return _showContexts;
|
||||
}
|
||||
|
||||
public void setShowContexts(boolean show)
|
||||
{
|
||||
_showContexts = show;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue