java类中抛出的异常如何显示在JSP页面中
我想用do.jsp来处理上传的文件,读取文件内容,如果文件不合规范就显示显示抛出的异常。把clspenxml.deal处理文件时抛出的异常显示在do.jsp页面中,如何显示?
try
{
clspenxml.deal( "d:\\upload\\" + myFile.getFileName() , comcd.trim() , userid.trim() , "CP",appcom.trim());
}
catch (Exception e)
{
out.println("Unable to deal the file.<br>");
out.println("Error : " + e.toString());
}
方法clspenxml.deal()在另外一个class文件中
public void deal( String infile ,String incom , String inuser , String msgtype,String company )
{
String filetype = "";
try
{
root = getElement( infile );
if ( root == null )
{
throw new Exception("报文格式有误:root is null ");
}
........
}
catch ( SQLException sqle )
{
System.out.println(" sqle: " + sqle.getMessage() );
}
catch (Exception ex1 )
{
System.out.println(" Exception: " + ex1.getMessage() );
}
}
就是如何把象throw new Exception("报文格式有误:root is null ");这样的显示在do.jsp页面中。