ShowError.jsp 3.89 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8"  isErrorPage="true" language="java" %> 
<%@ page import="java.util.Date,java.util.Locale,java.text.SimpleDateFormat" %>
<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*,org.jdom.*,java.util.*,com.csc.library.utilities.*,com.csc.library.mail.*"  %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="./CSS/EMPLOYEE_VIEW.css" />
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="./JS/SCREEN.js"></script>
<style>
.errors {border:1px dotted #d21033; background:#fed url(./IMAGES/MSGERROR.gif) no-repeat 20px 18px; color:#d21033; padding-bottom: 40px;}
</style>
</head>
<body>
<%
	System.out.print(session.getAttribute("userprofile"));
	if(session.getAttribute("userprofile")== null ) {%>
	<script>

		if (window.opener) {
			console.log(1);
			window.opener.parent.top.location = "../LOGINERROR.jsp";
			close();
		}else if(window.parent.top.location){
			console.log(2);
			window.parent.top.location = "../LOGINERROR.jsp";
		}else{
			console.log(3);
			window.parent.location = "../LOGINERROR.jsp";
		}
	</script>
<%}%>
<%		  
  CheckNull chk=new CheckNull();
  ThaiUtilities th=new ThaiUtilities();
  InitialEnvironment en = new InitialEnvironment("GLOBAL");
  String from=en.getValue("MAILAUTH-username");
  String to="consult_myhr@yahoo.com";//"adminess@pttict.com";
  String cc="";
  String subject=chk.chkNullString(th.ASCII2Unicode(request.getParameter("__subject")));
  String content=chk.chkNullString(th.ASCII2Unicode(request.getParameter("__content")));
  String exceptionString = null;
  	if(subject.length()>0 && content.length()>0){			
		exceptionString=(String)session.getAttribute("errorOnpages");
		if(exceptionString!=null){
			session.setAttribute("errorOnpages",""); 				
			SendMail sm= new SendMail("", from,to,cc,subject,content+"<br>"+exceptionString );
			sm.send();
		%>
		<script language="javascript">alert("send mail complete...");</script>
		<%		
		 }else{
		%>
		<script language="javascript">alert("no error don't send mail...");</script>
		<%				
		}
	}else{
						final Exception  exception_ = (Exception)request.getAttribute("javax.servlet.error.exception");
						if(exception_ != null) {
							java.io.StringWriter stringWriter = new java.io.StringWriter();
							java.io.PrintWriter printWriter = new java.io.PrintWriter(stringWriter);
							exception_.printStackTrace(printWriter);
							exceptionString = stringWriter.toString();
							session.setAttribute("errorOnpages","<pre>"+exceptionString+"</pre>"); 
						   stringWriter.close();
						   printWriter.close();						   
					  }
	}
					%>
<form  name="cscform" method="post" action="ShowError.jsp">
<div class="errors" id="msgstatus">
	<div align="center">
			 <%//@ include file="../msg.jsp" %>
			 <span>ขออภัยค่ะ !</span> ระบบอาจจะเกิดข้อผิดพลาด<br /> กรุณาส่งรายละเอียดเกี่ยวกับข้อผิดพลาดลงในช่องด้านล่างแล้ว send เพื่อส่งให้ ผู้ดูแลระบบ
	</div>
						<p align="center" >subject:
						  <input type="text" name="__subject"  size="72"  /><br>
						  <textarea name="__content" cols="80" rows="20"><%out.println("error Code :"+request.getAttribute("javax.servlet.error.status_code") 
						  +"\nRequest URL: "+request.getAttribute("javax.servlet.error.request_uri") 
						  +"\nmessage :  "+exceptionString );
						  %>
						  </textarea>
						</p>
						  <label>
						  </label>
						<p align="center"><input name="submit" type="submit"  value=" SEND "></p>
</div>
</form> 

</body>
</html>