FileDocCategorySizeDatePackage
GetResource.javaAPI DocExample1084Sat Apr 23 22:35:38 BST 2005None

GetResource

public class GetResource extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

		URL url = getServletContext().getResource("/WEB-INF/web.xml");
System.out.println("url = "+url);

        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
		
        out.println("<html><body><h1>GetRes Response</h1>");
		out.println( getStringFromStream( url.openStream() ) );
		out.println("</body></html>");
		out.close();
    
public static java.lang.StringgetStringFromStream(java.io.InputStream ins)

		return getStringFromStream( new	InputStreamReader( ins ) );
	
public static java.lang.StringgetStringFromStream(java.io.Reader reader)

		StringBuffer sb	= new StringBuffer();
		BufferedReader br = new	BufferedReader(	reader );
		String line;
		while (	( line = br.readLine() ) != null )
			sb.append( line	+"\n");

		return sb.toString();