Example usage for javax.servlet.http HttpServlet getClass

List of usage examples for javax.servlet.http HttpServlet getClass

Introduction

In this page you can find the example usage for javax.servlet.http HttpServlet getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.zoxweb.server.http.servlet.HTTPServletUtil.java

public static String inputStreamToString(HttpServlet servlet, String resource)
        throws NullPointerException, IOException {
    log.info("resouce:" + resource);
    String content = null;//ww  w  .  j a v  a  2  s  . c o m
    try {
        content = (IOUtil.inputStreamToString(servlet.getClass().getResourceAsStream(resource), true));
    } catch (Exception e) {

    }
    if (content == null) {
        ServletContext context = servlet.getServletContext();

        URL url = context.getResource(resource);
        log.info("url:" + url);
        content = (IOUtil.inputStreamToString(context.getResourceAsStream(resource), true));
    }

    return content;
}