|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.oreilly.servlet.ServletUtils
public class ServletUtils
A collection of static utility methods useful to servlets. Some methods require Servlet API 2.2.
| Constructor Summary | |
|---|---|
ServletUtils()
|
|
| Method Summary | |
|---|---|
static java.net.URL |
getResource(ServletContext context,
java.lang.String resource)
Gets a reference to the given resource within the given context, making sure not to serve the contents of WEB-INF, META-INF, or to display .jsp file source. |
static Servlet |
getServlet(java.lang.String name,
ServletRequest req,
ServletContext context)
Gets a reference to the named servlet, attempting to load it through an HTTP request if necessary. |
static java.lang.String |
getStackTraceAsString(java.lang.Throwable t)
Gets an exception's stack trace as a String |
static void |
returnFile(java.lang.String filename,
java.io.OutputStream out)
Sends the contents of the specified file to the output stream |
static void |
returnURL(java.net.URL url,
java.io.OutputStream out)
Sends the contents of the specified URL to the output stream |
static void |
returnURL(java.net.URL url,
java.io.Writer out)
Sends the contents of the specified URL to the Writer (commonly either a PrintWriter or JspWriter) |
static java.lang.String[] |
split(java.lang.String str,
java.lang.String delim)
Splits a String into pieces according to a delimiter. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ServletUtils()
| Method Detail |
|---|
public static void returnFile(java.lang.String filename,
java.io.OutputStream out)
throws java.io.FileNotFoundException,
java.io.IOException
filename - the file to sendout - the output stream to write the file
java.io.FileNotFoundException - if the file does not exist
java.io.IOException - if an I/O error occurs
public static void returnURL(java.net.URL url,
java.io.OutputStream out)
throws java.io.IOException
URL - whose contents are to be sentout - the output stream to write the contents
java.io.IOException - if an I/O error occurs
public static void returnURL(java.net.URL url,
java.io.Writer out)
throws java.io.IOException
URL - whose contents are to be sentout - the Writer to write the contents
java.io.IOException - if an I/O error occurspublic static java.lang.String getStackTraceAsString(java.lang.Throwable t)
e - the exception
public static Servlet getServlet(java.lang.String name,
ServletRequest req,
ServletContext context)
name - the name of the servletreq - the servlet requestcontext - the servlet context
public static java.lang.String[] split(java.lang.String str,
java.lang.String delim)
str - the string to splitdelim - the delimiter
public static java.net.URL getResource(ServletContext context,
java.lang.String resource)
throws java.io.IOException
context - the context containing the resourceresource - the resource to be read
java.io.IOException - if there's any problem accessing the resource
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||