KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > servlet > ServletException

javax.servlet
Class ServletException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjavax.servlet.ServletException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
UnavailableException
See Also:
Top Examples, Source Code

public Throwable getRootCause()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ServletException()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ServletException(String message)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ServletException(String message,
                        Throwable rootCause)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ServletException(Throwable rootCause)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1619]Simple servlet that uses JAXP to produce dynamic output based on XML data documents and XSLT transforms
By Anonymous on 2005/11/04 20:23:08  Rate
import java.io.*; 
 import javax.servlet.*; 
 import javax.servlet.http.*; 
 import javax.xml.transform.*; 
 import javax.xml.transform.stream.*; 
  
  
 /** 
 Simple servlet that uses JAXP to produce dynamic output based on 
 XML data documents and XSLT transforms. 
 */
 
 public class KickJavaServlet 
     extends HttpServlet 
  {  
     /** 
     Create a Transformer and prime it with either the  < b > Summary.xsl < /b >  or 
      < b > Detail.xsl < /b > . Apply this to  < b > Listings.xml < /b >  and stream the  
     transform output to the HTTP response stream. 
     */
 
     public void doGet 
              ( HttpServletRequest request, HttpServletResponse response )  
         throws IOException, ServletException 
      {  
         response.setContentType  ( "text/html" ) ; 
         PrintWriter out = response.getWriter  (  ) ; 
  
  
         InputStream source = getServletContext  (  )  
             .getResourceAsStream  ( "/Listings.xml" ) ; 
  
  
         String level = request.getParameter  ( "level" ) ; 
         String xformFilename =  
             level == null || !level.equals  ( "Detail" )  
                 ? "/Summary.xsl" 
                 : "/Detail.xsl"; 
         InputStream transform =  
             getServletContext  (  ) .getResourceAsStream  ( xformFilename ) ; 
          
         try 
          {  
             TransformerFactory factory = TransformerFactory.newInstance  (  ) ; 
             Transformer transformer =  
                 factory.newTransformer  ( new StreamSource  ( transform )  ) ; 
             transformer.transform  
                  ( new StreamSource  ( source ) , new StreamResult  ( out )  ) ; 
          }  
         catch  ( Exception ex )  
          {  
             ex.printStackTrace  (  ) ; 
             response.sendRedirect 
                  ( request.getContextPath  (  )  + "/TransformFailed.html" ) ; 
          }  
      }  
  
  
     /** 
     Delegate to  { @link #doGet doGet } . 
     */
 
     public void doPost 
              ( HttpServletRequest request, HttpServletResponse response )  
         throws IOException, ServletException 
      {  
         doGet  ( request, response ) ; 
      }  
  }  
  
  
 

Popular Tags