public class Server extends Object
Constructor and Description |
---|
Server()
Creates a default instance of the server.
|
Modifier and Type | Method and Description |
---|---|
void |
addServletMapping(String pattern,
Class<? extends HttpServlet> servletClass)
Maps a new Servlet to the server with
default priority . |
void |
addServletMapping(String pattern,
Class<? extends HttpServlet> servletClass,
int processOrder)
Maps a new Servlet to the server.
|
void |
addServletMapping(String pattern,
String servletClass)
Maps a new Servlet to the server with
default priority . |
void |
addServletMapping(String pattern,
String servletClass,
int processOrder)
Maps a new Servlet to the server.
|
int |
deleteServletMapping(Class<? extends HttpServlet> servlet)
Delete all servlet mapping with the given class
|
int |
deleteServletMapping(String pattern)
Delete all servlet mapping with the given URL pattern
|
int |
deleteServletMapping(String pattern,
Class<? extends HttpServlet> servlet)
Delete all servlet mapping with matching URL pattern and servlet class
|
int |
deleteServletMapping(String pattern,
String servlet)
Delete all servlet mapping with matching URL pattern and servlet class
|
String |
getDefaultPage() |
int |
getMaxRequestBodySize() |
int |
getServerPort() |
String |
getStaticContentPath()
Obtain the path for the static content
|
boolean |
isShowError() |
static void |
main(String[] args)
Sample program to start the server
|
void |
setDefaultPage(String defaultPage) |
void |
setMaxRequestBodySize(int maxRequestBodySize) |
void |
setServerPort(int serverPort) |
void |
setShowError(boolean showError) |
void |
setStaticContentPath(String staticContentPath)
Set the path for the static content
|
void |
start()
Start the server with the current configuration.
|
public static void main(String[] args) throws Exception
args
- Parameter from command lineException
- Exceptionpublic void start() throws IOException
IOException
- The Server cannot be started because of IO exceptionspublic void addServletMapping(String pattern, Class<? extends HttpServlet> servletClass, int processOrder)
pattern
- The URL pattern which will trigger the servletservletClass
- The servlet Class object. Usually obtained by MyServlet.class
processOrder
- The priority for this servlet to be executed. The smaller the processOrder
is,
the higher priority this entry is.public void addServletMapping(String pattern, String servletClass, int processOrder) throws ClassNotFoundException
pattern
- The URL pattern which will trigger the servletservletClass
- The fully qualified name for the servletprocessOrder
- The priority for this servlet to be executed. The smaller the processOrder
is,
the higher priority this entry is.ClassNotFoundException
- The given class is invalidpublic void addServletMapping(String pattern, String servletClass) throws ClassNotFoundException
default priority
.
This operation can be performed after the server is started.pattern
- The URL pattern which will trigger the servletservletClass
- The servlet Class object. Usually obtained by MyServlet.class
ClassNotFoundException
- The given class is invalidpublic void addServletMapping(String pattern, Class<? extends HttpServlet> servletClass)
default priority
.
This operation can be performed after the server is started.pattern
- The URL pattern which will trigger the servletservletClass
- The fully qualified name for the servletpublic int deleteServletMapping(String pattern)
pattern
- The URL patternpublic int deleteServletMapping(Class<? extends HttpServlet> servlet)
servlet
- The servlet Class object. Usually obtained by MyServlet.class
public int deleteServletMapping(String pattern, Class<? extends HttpServlet> servlet)
pattern
- The URL patternservlet
- The servlet Class object. Usually obtained by MyServlet.class
public int deleteServletMapping(String pattern, String servlet) throws ClassNotFoundException
pattern
- The URL pattern, null
if this URL pattern should be ignoredservlet
- The fully qualified name for the servlet, null
if class name should be ignoredClassNotFoundException
- The given class is invalidpublic String getStaticContentPath()
public void setStaticContentPath(String staticContentPath)
staticContentPath
- path for the static contentpublic String getDefaultPage()
public void setDefaultPage(String defaultPage)
public int getServerPort()
public void setServerPort(int serverPort)
public boolean isShowError()
public void setShowError(boolean showError)
public int getMaxRequestBodySize()
public void setMaxRequestBodySize(int maxRequestBodySize)