java.lang.Object
java.lang.Throwable
java.lang.Exception
javax.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.*;
public class KickJavaServlet
extends HttpServlet
{
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" ) ;
}
}
public void doPost
( HttpServletRequest request, HttpServletResponse response )
throws IOException, ServletException
{
doGet ( request, response ) ;
}
}